Highlighted

add counter in addInstance

Avatar

Guest

21-11-2008

Hi,



I have create a sub form with an addInstance-feature. I also added a textbox and a numeric field. The text says Journey and the mumeric field is empty, but has a script to add +1. The result in the PDF is Journey 1 as title. When I click the + button, the new sub form gets the name Journey 2.



The result is Journey 3 - Journey 2 then Journey 1 while it has to be journey 1 - journey 2 -journey 3



Can anyone help to get this in the correct order? Or is there another way to add a counter in a title?



The code I use now in FormCalc is:



Incitant7.subVoyage.subVoyage.subVoyagePers.subButtonPerson.fldPerson[*] = Sum(Incitant7.subVoyage.subVoyage.subVoyagePers.subButtonPerson.fldPerson.rawValue + 1)

Replies

Highlighted

pguerett

21-11-2008

Are you trying to get unique names for each of your fields in the repeating subform?



When you add an Instance of a subform it is the subform that gets the occurance number not the field ..... so in your above example if you have 3 occurances you woud have:



Incitant7.subVoyage.subVoyage.subVoyagePers.subButtonPerson[0].fldPerson

Incitant7.subVoyage.subVoyage.subVoyagePers.subButtonPerson[1].fldPerson

Incitant7.subVoyage.subVoyage.subVoyagePers.subButtonPerson[2].fldPerson



That makes each occurance of fldPerson unique and by knowing the subform ocurance you know which row it belongs to.
Highlighted

Avatar

Guest

24-11-2008

Paul,



I don't realy understand what you mean!



My goal is when I click the button the form should give me the title journey1 for the first, then i fill in the fields and when I click again he would need to give me Journey 2 for the second one which would be new empty fields. Now I have Journey 1 for the new added subform which is empty and journey 2 for the subform I have filled in first.
Highlighted

Thomas_McConnac

24-11-2008

Hi Bjorn,



Paul is saying that how you are addressing the field is incorrect.



Incitant7.subVoyage.subVoyage.subVoyagePers.subButtonPerson.fldPerson[*]



This is addressing an array of fields called "fldPerson" on a subform, but actually there is no array of fields. Instead there is an array of subforms so you must use:



Incitant7.subVoyage.subVoyage.subVoyagePers.subButtonPerson[*].fldPerson



And I have no idea if "*" will work for addressing the fields.