You are here: Function Reference > Alphabetical Listing > C > Count

Count

Use this function to count the number of fields that have values and have names that begin with common characters. The result of the operation is returned.

Syntax

Count (PartialField, Section, Form, Group)

Parameter

Description

PartialField

Enter a valid string. The string must be the common (prefix) portion of a set of field names that occur on the current section. The default is the current field.

Section

Enter the name of a section that contains the field you specified. The default is the current section.

Form

Enter the name of a form that contains the section and/or field you specified. The default is the current form.

Group

Enter the name of the form group that contains the form, section, and/or field you specified. The default is the current group.

This function returns the number of fields that have values that begin with the specified partial field name.

An example of field names that have a common start are:

Myfield1
Myfield2
Myfield20

Each of these fields will be included if the partial field name is using any of the leading characters of myfield. The first field will be excluded if you enter myfield2, but will match the other two field names.

Note that zero (0) is a valid field value. A field that has never been given a value is excluded from the count.

Note As a general rule, include the PartialField parameter. Fields in a section must have unique names. Using the default will probably not give the expected result, unless you created the form and understand the naming conventions.

Example

Here are some examples:

The following table will be used by the examples. The table represents the layout of two forms in the same group. Both forms share two sections (IMG A and IMG B). Each section has fields of the same name as a field in the other section.

Field

Section

Form

Group

Value

MyField1

IMG A

FRM A

GRP

100.24

MyField2

IMG A

FRM A

GRP

200.16

MyField1

IMG B

FRM A

GRP

98.60

MyField2

IMG B

FRM A

GRP

* no value yet *

MyField1

IMG A

FRM B

GRP

0.00

MyField2

IMG A

FRM B

GRP

* no value yet *

MyField1

IMG B

FRM B

GRP

70.77

MyField2

IMG B

FRM B

GRP

* no value yet *

(Assume the current field is MyField1, on the first section of the first form. Reference the previous table for field values.)

Function

Result

Explanation

Count( )

1

Without any other information, the function will assume the current field and section. There will only be one value included in the count.

Return(Count ( "Myfield2"))

1

Again, there is only one field included in this result.

Return(Count ( "MyField"))

2

In this example, the current section contains two fields that begin with the name "MyField".

Return(Count ( "MyField", "IMG B"))

1

Although two fields on IMG B have a matching name, only one field actually has a value.

Return(Count ( "MyField", , "FRM A"))

3

No section is specified in this example, so the entire form is searched. Four fields match the name criteria, but only three have values.

Return(Count ( "MyField", "IMG B", , "GRP"))

2

This example specifies a section and group, but no form. There are four fields that match the name criteria, but only two have values.

Return(Count ( "MyField", , , "GRP"))

5

This example names the group without a form or section. Eight fields meet the naming criteria, but only five fields actually have values.

See also