FIGURE 5.4The default references for a new Access 2003 database.
When using one of the Find*search methods (FindFirst, FindNext, and so forth),
save the search string to a variable, and display it in the Immediate window using a
Debug.Printstatement; this will be very helpful in debugging any problems because it shows you
exactly what expression is being used for the search.If you are working on a database originally created several Access versions ago, it might have
ambiguous declarations such as:Dim dbs As Database
Dim rst As RecordsetAs a demonstration of possible problems, the following procedure sets up a recordset and uses
FindFirstto locate the first match for “Microsoft” in the CompanyID field:Private Sub TestFindFirst()Dim dbs As Database
Dim rst As Recordset
Dim strSearch As StringSet dbs = CurrentDb
Set rst = dbs.OpenRecordset(Name:=”tblCompanyIDs”, _
Type:=dbOpenDynaset)
strSearch = “[CompanyID] = “ & Chr$(39) _
& “Microsoft” & Chr$(39)
Debug.Print “Search string: “ & strSearch
rst.FindFirst strSearchEnd SubTIPTIP
Working with Access Data 5