Link to home
Start Free TrialLog in
Avatar of kennys
kennys

asked on

Search a database table

A beginner asks

I am trying to search a database table called FLEET

The Field is called RegNo and I am getting a runtime error 3001 Invalid arguement at the following line
Recordset.FindFirst sCriteria

Can anyone show me where I am going wrong in the following code


Private Sub cmdSearch1_Click()
'Search RegNo field

Dim sCriteria As String
Dim sBkmark As String

Set Database = OpenDatabase(PathToDB)
Set Recordset = Database.OpenRecordset("SELECT * FROM Fleet")
   
sCriteria = Text1.Text

'remember where we were in case Search fails
sBkmark = Recordset.Bookmark

'Execute the find
Recordset.FindFirst sCriteria

'Check for success
If Recordset.NoMatch Then
    MsgBox "Record not found"
    'if failed return to last good record
    Recordset.Bookmark = sBkmark
    End If
    'Display the find in text box 6
    Text6.Text = Recordset!RegNo

End Sub
ASKER CERTIFIED SOLUTION
Avatar of jelliott720
jelliott720

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kennys
kennys

ASKER

Many Thanks