Hello,
I have a form I produced on LiveCycle Designer ES2. I don't have a LiveCycle Server product. I am learning how to code using LiveCycle.
The form has a subform ("Contactssubform") with the following fields: "FirstName", "MiddleName", and "LastName". There is a dataconnection ("ContactsSQLTableDataConnection") between the form and a SQL table ("ContactsSQLTable") - the table has fields "TableFirstName", "TableMiddleName", and "TableLastName. I want to be able to press a button on the form, and have the the # of instances of the Contacts subform be the same as the # of records in ContactsSQLTable. I then want the each Contactssubform instance filled with a record from ContactsSQLTable.
How do I code this in the Button click event?
I've done a lot of research in the forums/internet to try and figure out the code, but haven't been able to do so. I would have thought one could do something like this:
-Loop through the records of the ContactsSQLTable
-Add an Instance of the Contacts Subform for each record
-Fill in the fields in the subform instance with the data form the table record
e.g.
xfa.sourceSet.ContactsSQLTableConnection.Records.first;
for (x=1;x<xfa.sourceSet.ContactsSQLTableConnection.Records.Length;x++)
{
xfa.Formpage.Contactssubform.AddInstance(1);
xfa.Formpage.Contactssubform.FirstName = xfa.sourceSet.ContactsSQLTableConnection.Record.TableFirstName;
xfa.Formpage.Contactssubform.MiddleName = xfa.sourceSet.ContactsSQLTableConnection.Record.TableMiddleName;
xfa.Formpage.Contactssubform.LastName = xfa.sourceSet.ContactsSQLTableConnection.Record.TableLastName;
xfa.sourceSet.ContactsSQLTableConnection.Records.next;
}
I see instead I should be looping through the nodes of the data connection(?) Having trouble understanding how to do that.
Thank you for any assistance with this.
Andrew