Auto-fill fields in InfoPath from a drop-down list box selection
Auto-fill fields in InfoPath from a drop-down list box selection and
secondary data source
A D V E R T I S E M E N T
You can accomplish this functionality as follows:
Create a Microsoft Access database with a Fruits table
that has the fields ID (Autonumber), Name
(text), and Colour (text) as shown in figure 1.
Figure 1. Fruits table in Microsoft Access.
Design an InfoPath form template as shown in figure 2.
Figure 2. The InfoPath form template in design mode.
with a Main data source that resembles the following figure:
Figure 3. The Main data source of the form template.
Here you will populate the fruit drop-down list box with
items from the database table and then fill the colour
field with a value corresponding to the selected fruit from the drop-down
On the Tools menu, click Data Connections.
On the Data Connections dialog box, click Add,
and add a Receive data data connection to the
Fruits table you created in step 1.
Double-click on the fruit drop-down list box to open
its Properties dialog box.
Bind the fruit drop-down list box to the data
connection for the Fruits database table you created in
step 4 as shown in the following figure:
While you are still in the Properties dialog box of the
drop-down list box, click on the Rules button.
On the Rules dialog box, click Add.
On the Rule dialog box, click Add Action.
On the Action dialog box, select Set a field's
value from the Action drop-down list box, select
colour from the Main data source as the Field
to set, and then click on the formula button behind the Value
On the Insert Formula dialog box, click Insert
Field or Group.
On the Select a Field or Group dialog box, select the
secondary data source for Fruits from the Data
source drop-down list box, click on the Colour
node to select it, and then click on the Filter Data
On the Filter Data dialog box, click Add.
On the Specify Filter Conditions dialog box, select
ID from the first drop-down list box, leave the second
drop-down list box on is equal to, and select
Select a field or group from the third drop-down list box.
On the Select a Field or Group dialog box, choose
Main from the Data source drop-down list
box, click on the fruit node to select it, and then click
Your Specify Filter Conditions dialog box should resemble
the following figure:
Click on OK to close all open dialog boxes.
The final expression for the rule your added should resemble:
Set a field's value: colour = @Colour[@ID = fruit]
You should now have a fully functional form so that when you select a
fruit from the drop-down list box, its corresponding colour should
appear in the colour field.