Hi Kevin,
What you are seeing is expected behavior and discussed in this forum many
times - what you need to include is the "current()" function so you can get
the information from the "current" section you are working in. Here are
some sample steps that use the Microsoft Access Northwind sample database:
- Create a new, blank InfoPath form
- Add a data connection to the Northwind Customers table (you will only
need the CustomerID and CompanyName fields for this sample)
- Add a data connection to the Northwind Orders table (you will only need
the OrderID, CustomerID and Freight fields for this sample)
- Add a repeating section control to the form
- Add a drop-down box to the repeating section named: ddlCustomers
- Add another drop-down box to the repeating section named: ddlOrders
- Add a text box to the repeating section named: txtFreight
- Right-click on ddlCustomers and choose Properties
- In the List box entries section, choose: "Look up values in a data
connection to a database..."
- From the Data Connection box choose Customers
- Click the Select XPath button next to Entries, highlight d:Customers and
click OK
- Leave the Value field as CustomerID
- Click the Select XPath button next to Display name, highlight CompanyName
and click OK
- Right-click on ddlOrders and choose Properties
- In the List box entries section, choose: "Look up values in a data
connection to a database..."
- From the Data Connection box choose Orders
- Click the Select XPath button next to Entries, highlight d:Orders
** NOTE: The next steps are important for filtering the Orders to match the
selected customer! **
- Click the Filter Data button
- Click Add
- In the first box, select: CustomerID
- In the second box, select: is equal to
- In the third box, choose: Select a field or group
- From the Data Source box, choose Main
- Drill down, highlight ddlCustomers and click OK
- From the first box now, select The Expression - this will now show you
something like the following:
@CustomerID =
xdXDocument:get-DOM()/my:myFields/my:group1/my:group2/my:ddlCustomers
- Modify the expression so it looks like this:
@CustomerID = current()/my:ddlCustomers
- Click OK 4 times to get back to your form
** NOTE: The next steps are to set the txtFreight field based on the
selected order! **
- Right-click on ddlOrders and choose Properties
- Click the Rules button
- Click Add
- Click Add Action
- From the Action box, choose Set a fields value
- Click the button next to Field, highlight txtFreight and click OK
- Click the "fx" button next to Value
- Click Insert Field or Group
- From the Data Source box choose Orders
- Drill down and highlight Freight
- Click the Filter Data button
- Click Add
- In the first box, select: OrderID
- In the second box, select: is equal to
- In the last box, choose: Select a field or group
- From the Data Source box choose Main
- Drill down, highlight ddlOrders and click OK
- In the first box, choose The expression - this will now show you
something like the following:
../@OrderID =
xdXDocument:get-DOM()/my:myFields/my:group1/my:group2/my:ddlOrders
- Modify the expression so it looks like this:
../@OrderID = current()/../my:ddlOrders
- Click OK 8 times to get back to your form
** NOTE: These last steps are to clear the OrderID's each time you select a
new customer! **
- Right-click on ddlCustomers and choose Properties
- Click the Rules button
- Click Add
- Click Add Action
- From the Action box choose: Set a fields value
- Click the button next to Field, select ddlOrders and click OK
- Leave the Value field blank!
- Click OK 4 times to get back to your form
- Preview and test....after you select a customer, you should see just a
subset of the orders in ddlOrders. Once you make a selection from
ddlOrders, the freight amount should be populated in txtFreight.
- Insert a new item and repeat - you should be able to select a different
customer and order!
I know this is a long list of steps but hopefully it will help you to
understand where you will need to go in your solution.
Best Regards,
Scott L. Heim
Microsoft Developer Support
This posting is provided "AS IS" with no warranties, and confers no rights.