[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

Search a database table

Posted on 2000-02-11
2
Medium Priority
?
156 Views
Last Modified: 2012-05-04
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
0
Comment
Question by:kennys
2 Comments
 
LVL 1

Accepted Solution

by:
jelliott720 earned 400 total points
ID: 2511940
Assuming RegNo is numeric try..

sCriteria = "RegNo = " & Text1.Text

if RegNo is a string..

sCriteria = "RegNo = '" & Text1.Text & "'"

0
 

Author Comment

by:kennys
ID: 2512353
Many Thanks
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month11 days, 9 hours left to enroll

640 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question