Expand my Community achievements bar.

Transferring data from a subform into a table automatically

Avatar

Level 2

I have a form which includes a “+” button that adds an instance of a subform and adds a row to a table.  The table is the last page of the form and is basically a summary of the information that appears in the subform that is added when the user hits the + button.  I would like to copy some of the information in the subform into the table rows automatically.  I have been successful in getting the information in the 1st instance of the subform to copy into the table, but I want each subsequent subform which is added to transfer into the rows that are added.  Right now, each subsequent row contains the information in the 1st subform.  I’ve tried to use *, but can’t make it work.

This is what I have now:

var intTotal = form1.Subform9[*].NumericField27[*]

Can someone tell me if what I am trying to do is possible and how to make it work?  THANKS!!!

6 Replies

Avatar

Level 7

The * gives all things with that name so use that if you want to add all the things in the various subforms together, but if you want to display them seperately in the table at the end you want to reference the row index in the table to match the number of the subform (eg. the first row of the table has an index of [0] which is the same as the 1st subform so use form1.Subform9[0].NumericField27, and then the next one is [1] etc).

Avatar

Level 2

Thanks for the response.  I think I understand what you are saying.  My issues is that becuase I have a button that adds the subform and the rows simultaneously, there isn't a field to go to and add the [1]. Also, let me clarify, I'm not actually doing any sort of mathematical calculation, I just want to copy the info (number or text) from one field to the other.  I've been racking my brain and looking on-line, and I found this script:

ContactName.rawValue = this.rawValue;

Which I modified to this:

form1.Subform8.Table5[0].Row2.TextField47.rawValue

=

this.rawValue

But it isn't working.   I am in human resources and this technical language is out of my knowledge base.  Any help you can provide would be really helpful.  Thanks!!!

Avatar

Level 2

Maybe I need to reference instancemanager somewhere in there?

Avatar

Level 7

What you need to do is name all your table rows the same thing (so say Row1) and then it will automatically call them Row1[0], Row1[1],Row1[2] etc. Then in your table at the end in each row put a text field (or numericfield) and in the calculate event for that field put (in formcalc):

$ = Subform9[$.parent.index].NumericField27 (or whatever you have called your subform and the field you want to reference).

The important part is the [$.parent.index] which says that in Row1[0] put the information which is in Subform9[0].NumericField27 which is the first instance of your subform, and then in Row1[1] (which is the second row) put the information which is in Subform9[1].NumericField27 which is the second instance of your subform, etc.

Avatar

Level 2

Thanks for your help.  My iT department helped me, but we went a different route... and it still isn't working.  We added a variable called InstanceCnt which is var oDetailPageReg = null; and I am trying to reference it in s script which starts with InstanceCnt.oDetailPageRef  But the program isn't finding my variable.  Any thoughts on why?

Thanks again.

Avatar

Level 7

Where did you define the variable? To make it a form variable you need to define it under File > Form Properties > Variables.