O'Reilly logo

Access 2003 VBA Programmer's Reference by Armen Stein, Graham Seach, Teresa Hennig, Patricia Cardoza

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

I.2. Find Records

Access provides a way to search for records, but it leaves a lot to be desired. The binoculars button pops up a dialog box with several search options, but most users don't know how to use it properly. The problem is that it is has too many options, when your user probably just wants to find a record containing a certain text value.

Instead of the dreaded binoculars, you can include a quick and easy way for your user to find records. Figure I-4 shows a form with a built-in technique to find records.

Figure I.4. Figure I-4

This record finding technique allows any phrase to be entered in the text box, then finds the first (or next) record that contains that phrase anywhere in the displayed fields. Alternatively, the user may use the radio buttons to switch to an exact match instead of a contains search, where the entire field must match the phrase. This exact mode is not used very often, but it can be handy in searching for exact codes or numbers (such as membership or account numbers).

I.2.1. Call ng the Record Finder Code

The On Click event of the Find button (shown in Figure I-4) includes this code:

Private Sub cmdFirst_Click()
On Error GoTo Error_Handler

    FindRecordLike "first"
Exit_Procedure: On Error Resume Next Exit Sub Error_Handler: MsgBox "An error has occurred in this application. " _ & "Please contact your technical support person and tell " _ & "them ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required