I think I may have figured out a solution to the first problem...I use VBScript code to accomplish the task. Basically, the code is written into the OnAfterChange event of the drop down list box, so that it executes/updates every time a change is made to a drop down in any of rows of the repeating table. I use two data sources: First is the main data source which is where the fields that the controls (the drop down and the text box) bind to are located. Second is a secondary data source which contains the statutes table.
Dim test
Dim i
Dim temp
Dim temp2
Dim queryString
'Gets the data for the rows in the repeating table (the repeating table is bound to group2)
set test = XDocument.DOM.selectNodes("/my:myFields/my:group1/my:group2")
'the code below loops through each row of the repeating table and for each drop down that is not blank or null, it queries the secondary data source with the offenseID from the drop down and finds the corresponding statute, then puts that statute number into the text box in the form control
for i=0 to (test.length-1)
'get the offense number from the drop down
temp = test.Item(i).getAttribute("my:offense")
'make sure the offense isnt blank or null...important!
if (not(IsNull(temp)) and temp<>"") then
'build the string which will form the query
queryString = "Select * from StatuteTable where OffenseID=" + temp
'query the secondary data source
XDocument.DataObjects("StatuteTable").QueryAdapter.Command=queryString
XDocument.DataObjects("StatuteTable").Query()
'get the resulting data from the secondary data source after it has been queried
set temp2 = XDocument.DataObjects("StatuteTable").DOM.getElementsByTagName("d:StatuteTable")
'Set the statute field in the main data source to the value found in the secondary data source
test.Item(i).setAttribute "my:StatuteTextBox", temp2.Item(0).getAttribute("StatuteNumber")
end if
next
*Note: your XPaths for accessing the data sources may differ depending on how you set up your form (started from scratch, started from a data connection, etc) as well as the differences in how you named your tables and/or fields...if you have any questions, feel free to ask