ChildFields.Count property

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF Merger for COM/ActiveX (v3)  /  ChildFields.Count property

DynamicPDF Merger for COM/ActiveX (v3) Forum

 Aug 13 2006 1:43 AM
Is there a way to return the correct form field count?

It appears the ChildFields.Count property is not able to properly count form fields with a dot or period (.) in the field name if the fields are not named uniquely on the left hand side of the dot.

For instance a PDF with two text controls, txt.1 and txt.2 will cause the count property to return an incorrect value of 1.  It should return 2.

Both Adobe Acrobat and DynamicPDF Merger routinely use the dot notation to distinguish between fields of similar names but either on different pages or as an array of controls.

Acrobat has a feature for replicating controls on a form. This tool modifies controls at design time to append a .n notation where n is the index of the control.
 Aug 14 2006 9:20 AM
Posted by a ceTe Software moderator
Hello,

The most likely reason the Count property is returning the value one where you have two fields txt.1 and txt.2 is because you are accessing only the container field. You have to use the ChildFields.Count property on the "txt" field and it will return the correct number of fields (i.e. two). In order to access any form field you have to use its full name.

The sample code below will return the count of the child fields:

Sample Code:
MyDocument.Form.Fields.Item("txt").ChildFields.Count

Thanks,
ceTe Software Support Team
 Aug 22 2006 1:12 PM
Maybe I'm missing something.  Can you tell me how to get the total field count without knowing the field names in advance?
 Aug 22 2006 4:26 PM
Posted by a ceTe Software moderator
Getting the total field count will require recursively counting the total number of child fields of each field.  Take a look at our "FormFieldReader.asp" example that is downloaded with the evaluation version.  This example uses a recursive function called "CreateList" to get the field type of each form field.  You could use this same type of logic and add a counter to keep track of the total number of fields.

Thanks,
ceTe Software Support Team

All times are US Eastern Standard time. The time now is 10:53 AM.