DekGenius.com
[ Team LiB ] Previous Section Next Section

Recipe 14.4 Fill the Drop-Down Lists When Using ServerFilterByForm in an ADP

14.4.1 Problem

You have turned on the ServerFilterByForm property. However, when users open the form and select from the combo boxes, the only choices are Is Null and Is Not Null. How do you get the combo boxes to show a list of valid values for that field?

14.4.2 Solution

If you turn on the ServerFilterByForm property, your form will open in a special view that turns text boxes into combo boxes. This allows users to define their own server filters at runtime, which are then processed by SQL Server before the record source data is returned to the form. However, you'll often see only the values shown in Figure 14-8 when you expand one of the combo boxes.

Figure 14-8. Combo boxes with only Is Null and Is Not Null options
figs/acb2_1408.gif

Each text box on the form has a FilterLookup property that has three settings:


Never

A combo box list will contain only two items: Is Null and Is Not Null.


Always

A combo box with a full list of values will be created for that text box.


Database Default

Access will populate the list either with all the values or with only Is Null/Is Not Null, depending on the settings in the Edit/Find tab of the Tools Options dialog shown in Figure 14-9.

Figure 14-9. Database options that affect ServerFilterByForm
figs/acb2_1409.gif

Follow these steps to change the database defaults to always show a list of available items when using ServerFilterByForm:

  1. Open the database whose options you want to change.

  2. Choose Tools Options from the menu.

  3. Check the "Records at server" option shown in Figure 14-9.

If you don't want to change this option globally, followthese steps to set the list of values on a form-by-form basis:

  1. In design view, open the form in which you want to enable a full list of values for ServerFilterByForm. Select all the text boxes you want to enable.

  2. Set the FilterLookup property on the Data tab in the properties sheet to Always, as shown in Figure 14-10.

Figure 14-10. Set the FilterLookup property for the control on a form
figs/acb2_1410.gif

When you open the form to filter records now, you'll see some real data in the combo boxes, as shown in Figure 14-11.

Figure 14-11. The combo boxes now display real data
figs/acb2_1411.gif

14.4.3 Discussion

The data to populate the combo boxes must, of course, come from the server. Setting the FilterLookup property for the controls or setting the "Records at server" option for the entire project runs additional queries that populate each combo box with a domain of real values from which the user can choose.

When you set the ServerFilter property on a form, regular filtering with the form's Filter property is unavailable.


Because populating combo boxes with real values entails extra round trips to the server to retrieve the data for the lists, it defeats the purpose of using the ServerFilter property in the first place, so don't overuse this feature. The benefit is that the interface is more user-friendly when the user can select from actual values instead of guessing.

You'll have to evaluate your own applications to determine whether or not the extra data filtering is worth the extra load on the server. If the form would otherwise load a lot of records, and if the lists you are loading aren't too big, you would probably improve performance by using ServerFilterByForm. To be safe, adjust the ServerFilterByForm setting at the control level rather than by setting the database default for the entire project.

    [ Team LiB ] Previous Section Next Section