Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Custom Find, Find Next

Status
Not open for further replies.

WalksWithSky

Instructor
Dec 11, 2002
49
CA
Hello:

Working on making a custom Find feature on a form, with two buttons: one button displays in input box where the user inserts the text they wish to find (this finds the first record) the second button uses the same value inserted in the input box and acts as a find next.

The problem is this: if I search for Green, and there are 5 records with Green, it shows the 5 records, but then the button acts as a next record button -- it kicks out the search criteria after it finds all the records and becomes a next record button.

Here's the code for the second button. strSearch is a public variable (input box where user enters search words)Any help would be appreciated:

Code:
Private Sub Command5_Click()
    Dim rs As DAO.Recordset
    Set rs = Me.RecordsetClone
   
    If Len(strMyValue) > 0 Then
        DoCmd.GoToRecord , , acNext
        DoCmd.FindRecord strSearch, acAnywhere, , , True, acAll, False
    End If
    If rs.NoMatch Then         
MsgBox "No Results Found"
    End If

Walks With Sky
 
I think you are mixing up form code and recordset code.

I believe the rs.findfirst "MYField = " & me.strmyvalue is what you want. There are also some options in findfirst that I think exist - like starting after the first and etc.

If you donot solve it let me know.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top