I have the following code on a form to look up last names that sound like XXXXX. The code works but only finds the first occurance. Can anyone tell me how to modify this code to show all the records that meet the search criteria.
Thanks
Dom
Thanks
Dom
Code:
Option Compare Database
Option Explicit
Sub txtFindIt_AfterUpdate()
Dim objTabs As Object
Dim stLike As String
Dim rs As Recordset
Dim db As Database
Dim ws As Workspace
Dim BkMark As String
Dim Criteria$
Dim cFindWhat As String
cFindWhat = Me.txtFindit & " " 'The empty Space avoids a possible Null error
Me.Painting = False
Set db = DBEngine(0)(0)
Set ws = DBEngine.Workspaces(0)
Set rs = Me.RecordsetClone 'Make a clone to look up values
BkMark = Me.Bookmark 'Mark where we are now
stLike = "'" & Trim(cFindWhat) & "*'" 'Add the wildcard..
Criteria$ = "LastName Like " & stLike
rs.MoveFirst
rs.FindFirst Criteria$
If Not rs.NoMatch Then
BkMark = rs.Bookmark
End If
Me.Bookmark = BkMark
rs.Close
Me.Painting = True
DoCmd.Hourglass False
Me.txtFindit = ""
End Sub