|
7.5. Populate a Control from a Data SourceThe previous section shows you how to use a database as the primary data source for a form, but you had to know customer or employee codes for the query to work. It would be better if those codes were listed in drop-down list boxes so you could just choose the right criteria (Figure 7-23). Figure 7-23. Modify the previous sample to populate listboxes from the database7.5.1. How to do itIn order to populate a listbox from a database, you need to establish a secondary data source. To add a secondary data source to the sample form:
7.5.2. How it worksYou can have multiple secondary data sources for a form. Each data source may be queried when the form loads depending on the setting in the last step of the Data Connection Wizard (Figure 7-29). If the data source is not queried at form load, or if it needs to be updated, you can refresh the secondary data source by adding a Button control to the form and selecting the Refresh action as shown in Figure 7-30. Figure 7-26. Set the XPath for Entries, Value, and Display name fieldsFigure 7-27. List control populated with customersFigure 7-28. Settings to populate the Employee listInfoPath creates a schema component file in the form template for each secondary data source you use. You can examine those schemas if you extract the form files from the template. |
|