Findfirst failing with a variable drawn from an autonumber field. (1 Viewer)

byterbit

New member
Local time
Today, 07:20
Joined
Feb 22, 2011
Messages
7
Findfirst failing with a variable drawn from an autonumber field.

That about says it; I grab a variable from the key field (an autonumber) and then turn it into a string ( Ive tried all the ways possible I think ) to find it against a text field.

So, in the code I do

vcard_fkey = Me!ID

and then I try

rs.FindFirst "fkey=" & vcard_fkey & "and type = 'card'"
and it blows up with a “data type mismatch in criteria expression”

I then try casting the variable into a string(no good), and then I declared it as a string(no good) and then I checked it was a string with
MsgBox TypeName(vcard_fkey)
And , indeed it was a string, and yes, fkey is a text field
And it all worked the other way, when fkey was a number field, but I needed it as a text



so let me add:

Help !
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 04:20
Joined
Aug 30, 2003
Messages
36,125
As answered elsewhere, try

rs.FindFirst "fkey='" & vcard_fkey & "' and type = 'card'"
 

Users who are viewing this thread

Top Bottom