Hi,
You will need to write some code to accomplish what you need - here are
sample steps using VBScript:
- Create a new, blank InfoPath form
- From the Tools menu choose Form Options
- Select the Advanced tab and insure the Programming Language is set to
VBScript
- Add a text box control (named field1), a Repeating Table with 2 columns
and a button to the form
- Right-click on the Repeating Table and choose Properties
- Select the Advanced tab
- In the section "Code: xmlToEdit Names" section, copy the "group" name
(i.e. group2_1)
- Right-click on the button and choose Properties
- Click the Edit Form Code button - you should see basically the following:
Sub CTRL6_5_OnClick(eventObj)
End Sub
- Add the following code before the End Sub line:
Dim i
Dim objField1
Set objField1 = XDocument.DOM.selectSingleNode("my:myFields/my:field1")
for i = 1 to objField1.text
XDocument.View.ExecuteAction "xCollection::insert", "group2_1"
next
Set objField1 = Nothing
- The entire procedure should now look like this:
Sub CTRL6_5_OnClick(eventObj)
Dim i
Dim objField1
Set objField1 = XDocument.DOM.selectSingleNode("my:myFields/my:field1")
for i = 1 to objField1.text
XDocument.View.ExecuteAction "xCollection::insert", "group2_1"
next
Set objField1 = Nothing
End Sub
- Save and close the code editor
- Save the sample form
- Preview and test: enter a 5 in the text box and click the button - you
should get 5 new rows added!
I hope this helps...
Scott L. Heim
Microsoft Developer Support
This posting is provided "AS IS" with no warranties, and confers no rights.