[ Team LiB ] |
Recipe 14.4 Fill the Drop-Down Lists When Using ServerFilterByForm in an ADP14.4.1 ProblemYou 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 SolutionIf 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 optionsEach text box on the form has a FilterLookup property that has three settings:
Figure 14-9. Database options that affect ServerFilterByFormFollow these steps to change the database defaults to always show a list of available items when using ServerFilterByForm:
If you don't want to change this option globally, followthese steps to set the list of values on a form-by-form basis:
Figure 14-10. Set the FilterLookup property for the control on a formWhen 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 data14.4.3 DiscussionThe 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.
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 ] |