Hello,
I have an infopath07 template I am working on. I have a main source with a repeating table, with two fields, Client and Job name. These fields are being populated from an Access Database(set up as a secondary source), where each Job name is specific to the Client.
I have the Client field in my form as a drop-down list being autopopulated from the secondary source.
What I want to do is search the database for all the Job names for the client I choose and then create a new row in a repeating table, and fill the Job name(in that row) with each job. Then be able submit this back to the database.
So the end result would be something like this: I choose a Client in the table, then I click a button, this creates a row for each job there is and fills the job name in there, then I submit this back to the database.
I've found some bits of code but it will only make 1 row and populate it with the first job in the database.
'get external data source
Dim MasterDataSource As DataSource = DataSources.Item("Master")
'get values from a couple of fields
Dim xpath As String = "/dfs:myFields/dfs:dataFields/d:Backup_Tracker/@Company_Name"Dim field1 As XPathNavigator = MasterDataSource.CreateNavigator().SelectSingleNode(xpath, NamespaceManager)
xpath =
"/dfs:myFields/dfs:dataFields/d:Backup_Tracker/@Job_Name"Dim field2 As XPathNavigator = MasterDataSource.CreateNavigator().SelectSingleNode(xpath, NamespaceManager)
'clone last repeating table row
xpath =
"/my:myFields/my:group1/my:group2[last()]"Dim oldGroup As XPathNavigator = MainDataSource.CreateNavigator().SelectSingleNode(xpath, NamespaceManager)
Dim newGroup As XPathNavigator = oldGroup.Clone()
'insert the new group
oldGroup.InsertBefore(newGroup)
'set the values of the fieldsnewGroup.SelectSingleNode("my:client", NamespaceManager).SetValue(field1.Value)
newGroup.SelectSingleNode(
"my:job.name", NamespaceManager).SetValue(field2.Value)