Share this Page URL

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

Adding Features and Function to Forms 293 The filter named CountryFilter, which you can find in the list of queries for the HelloWorld8 database, contains a criteria expression much like the expression we added to the CampaignExpenses form in the previous procedure, except the expression points to the list box for campaigns (lstCampaigns) in the ExpenseViews form. If you want to look at the expression, open CountryFilter in Design view. When you provide input to a filter by using a control's value, you need to apply the filter as well as specify the criteria in order to see the set of records that match the criteria. In the next steps, we'll modify the Click event procedure of the View Expenses button so that it applies the CountryFilter after it opens the query that shows the expenses for each campaign. Use the ApplyFilter method in an event procedure 1. 2. 3. Open the ExpenseViews form in Design view. Right-click the View Expenses button, and then click Build Event. In the Select Case statement, add the following statement to the end of the block of code for Case Is = 2: DoCmd.ApplyFilter("CountryFilter") DoCmd.SetWarnings False Here's how the code for the entire procedure should appear: