Share this Page URL

Chapter 8. Adding Features and Function ... > Running a Visual Basic Procedure by ... - Pg. 301

Adding Features and Function to Forms 301 5. 6. 7. 8. Here's another use for the value in the Categories list box-identifying the category of expenses we're viewing. When the CampaignExpenses form opens, the value of the text box txtExpense will be set to the value selected in the Categories list box. Close the Visual Basic Editor, and then select the text box at the top of the form. In the Properties dialog box, click the Data tab, and then delete the expression = "Campaign Expenses" from the Control Source property. Save your changes to the CampaignExpense form, close it, and then open the ExpenseViews form in Form view. Select an expense category, and then click View Expenses. When the CampaignExpenses form opens, the text box displays the category you selected, as shown here: When checking expenses, we'd like to know that the expense records are current. Another way we might use the Open event for the ExpenseViews form is to run a variation of the Import procedure we developed in Chapter 5. The procedure could check the last time the CampaignExpenses table was updated, and if records hadn't been updated that day, it would import expense records from the spreadsheet where they're maintained before displaying the form. Just the Steps Create an event procedure for a form's event 1. 2. 3. 4. 5. Open the form in Design view, and then open the Properties dialog box by clicking Properties on the toolbar. In the Properties dialog box, click the Event tab. Click in the event property box for the event you want to use, and then click the Build button. In the Choose Builder dialog box, indicate whether you want to build a macro, an event procedure, or an expression, and then click OK. Add the actions or code that you want to run when the event occurs.