Share this Page URL

Chapter 8. Adding Features and Function ... > Using a Control's Value in Query and... - Pg. 291

Adding Features and Function to Forms 9. 291 10. 11. 12. If the Properties dialog box isn't open, right-click the Expense Categories list box, and then click Properties. On the Other tab of the Properties dialog box, enter lstCategories in the con- trol's Name property. Click the Data tab, and change the Bound Column property from 1 to 2. Even though this list box is not a bound control (it displays Unbound in Design view and has no entry in its Control Source property), we're taking this step because we want to use the names of the categories, rather than the ExpenseTypeID number, in later examples. The Bound Column property determines which column in the list box provides a value. Repeat step 9 for the Campaigns list box, and enter the name lstCampaigns. Save the changes you've made to the ExpenseViews form, and then close the form for now. We now have the list boxes set up. In the next set of steps, we'll use expressions that refer to the list boxes so that the item selected in the list box is used as the criterion for a parameter query and a filter. In building the parameter query, we'll modify the record source of the form named Expen- sesByCategory, which is a subform embedded in the CampaignExpenses form. For the filter, we've created a filter (named CountryFilter) that will be applied to the ExpenseReport query when it's opened by the View Expense button's Click event procedure. Selecting multiple items in a list box List box controls have a property named Multi Select. The default value for this property is None, which means that only a single item in the list can be selected at one time. Setting this property to Simple lets you select more than one item in the list box by clicking the items or by pressing the Spacebar. The setting Extended lets you select multiple items using the Shift and Ctrl keys with the mouse. You can use the list box control's ItemsSelected collection to determine which items in the list are selected.