Need help with findfirst command (1 Viewer)

grahamw

Registered User.
Local time
Yesterday, 18:06
Joined
Aug 19, 2005
Messages
23
Dear all.
I am no expert at access but have managed to successfully code what Ive needed so far using the 'move' commands.
However, the findfirst command will allow me to find the first record meeting a condition I set- but I cant seem to get it working.
I basically want to find the first record under the 'race_num' field that is equal to 2332.
Ive tried .findfirst "race_num = 2332" but its not worked
(Im working from a wrox access2000 book)
My code is below:
Sub trying_out_seek()

Dim rec As Recordset
Dim db As Database

Set db = CurrentDb()
Set rec = db.OpenRecordset("RI_test0305", dbOpenDynaset)

rec.FindFirst "race_num = " & 2332


Debug.Print rec(5)

End Sub


PS. I get a run-time error 3464
I would be very grateful if anyone can help me out.
Best Wishes,
Graham , England
 

llkhoutx

Registered User.
Local time
Yesterday, 20:06
Joined
Feb 26, 2001
Messages
4,018
You're code appears to be correct for Access 97.

However, Error 3364's definition is: "Data type mismatch in criteria expression."

Make sure the race_num field of table RI_test0305 is numeric. If it's a text use


rec.FindFirst "race_num = '" & 2332 & "'"

I'm not sure what your Debug.Print rec(5) statement will give; probably an error.
 

grahamw

Registered User.
Local time
Yesterday, 18:06
Joined
Aug 19, 2005
Messages
23
Working now. Thanks very much for your help.
 

Users who are viewing this thread

Top Bottom