Table question

W

WM

Hi there. Is it possible to select a number from a drop down box, and use
this number to select the number of rows in a table. For example I you picked
the number 7 from a drop down box, could this number (7) be used to display a
table with 7 rows?

thanks
 
S

Scott L. Heim [MSFT]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top