ChildFields.Count property

ChildFields.Count property

Forum member · Aug 13, 2006
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.

Re: ChildFields.Count property

Support · Aug 14, 2006
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

Re: ChildFields.Count property

Forum member · Aug 22, 2006
Maybe I'm missing something. Can you tell me how to get the total field count without knowing the field names in advance?

Re: ChildFields.Count property

Support · Aug 22, 2006
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