8.4. Specifying Filters on InfoPath Forms

When working with data located in a Web service or database you can limit the amount of data, or filter, by using the query fields. There are times when it is convenient to limit data when using a standalone form as well. One way to do this is to specify filters, which can be done for a whole form, or individual repeating tables.

The way to accomplish filtering is by setting the Filter Data properties on a repeating table or section, located on the Display table in the property sheet, and pointing them to another control containing the values to filter for, such as a drop-down list box. You can see an example of this in Figures 8-11 and 8-12, where first all records are displayed,

Figure 8.11. Figure 8-11

Figure 8.12. Figure 8-12

8.4.1.

8.4.1.1. Try It Out: Filtering a Repeating Table Using a Drop-Down List Box

For this task, you will make a new blank InfoPath form that will create a list of employees with their type.

  1. Open InfoPath.

  2. Click on Design a Form.

  3. Click New Blank Form....

  4. Add a Repeating Table control from the Repeating and Optional section of the Controls task pane. The Insert Repeating Table dialog box will open, as shown in Figure 8-13, with the default value of three columns displayed.

    Figure 8.13. Figure 8-13
  5. Click OK.

  6. Add text and text boxes for Last Name, First Name, and Employee Type, naming the text boxes as the labels are, without the spaces. You can see the EmployeeType field displayed in Figure 8-14.

    Figure 8.14. Figure 8-14
  7. Click OK to accept the EmployeeType field.

  8. Add a Drop-Down List Box control, naming it ddEmployeeTypeFilter.

  9. Add the values Display All, Full Time, and Part Time for the list box entries, as displayed in Figure 8-15.

  10. Click OK to accept the properties for ddEmployeeTypeFilter.

  11. Right-click the label for the repeating table, and choose Repeating Table Properties.

  12. Click the Filter Data... button on the Display tab. The Filter Data dialog box opens.

  13. Click the Add... button. The Specify Filter Conditions dialog opens.

  14. Choose Select a field or group, then ddEmployeeTypeFilter for the first box. Choose Is equal to in the second box

  15. Choose Select a field or group and then EmployeeType for the third box.

  16. Click the And button to add another condition.

  17. Select "or" in the fourth box.

    Figure 8.15. Figure 8-15
  18. Choose Select a field or group and then ddEmployeeTypeFilter for the first box in the second row.

  19. Type Display All without the quotes in the third box. The Specify Filter Conditions dialog box should now look as it does in Figure 8-16.

    Figure 8.16. Figure 8-16
  20. Click OK to accept the filter conditions.

Now when you click Preview Form, you can enter data and see it filtered as shown in Figures 8-11 and 8-12.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.148.102.166