HandsOn Using Intrinsic Constants in a VBA Procedure

1. Open any form in Design view. You can use the Customers form in the Acc2003_Chap01.mdb file that you worked with in Chapter 1.

2. In the Design view of the chosen form, choose Edit | Select Form.

3. Choose View | Properties.

4. Click the Event tab in the Form properties sheet.

5. Click the Build button (...) to the right of the On Filter property, and select Code Builder.

6. In the Code window, enter the Form_Filter event procedure code as shown below.

7. Switch back to Design view in the Customers form and choose View | Form View. If you are using your own form for this hands-on, switch to Design view of your form and open it in Form view.

8. Choose Records | Filter | Filter By Form. Access displays the message "You need authorization to filter records." The same message appears when you choose Records | Filter | Advanced Filter/Sort.

Private Sub Form_Filter(Cancel As Integer, FilterType As Integer) If FilterType = acFilterByForm Or _ FilterType = acFilterAdvanced Then MsgBox "You need authorization to filter records." Cancel = True End If End Sub

Introduction to Access 2003 VBA Programming

0 0

Post a comment