Run-time error "13" Type mismatch (1 Viewer)

Pavczech

Registered User.
Local time
Today, 09:45
Joined
Jul 11, 2012
Messages
41
Hi to all

I have trouble with this line in my code.

rs.FindFirst "[Surname] = " & Var(Nz(Me![Text185], 0))


I think it is because it is not number but text.

Could somebody help

Thanks
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 09:45
Joined
Sep 12, 2006
Messages
15,653
not sure about "var" but you need the search string wrapped in "" chars.
i normally use chr(34) for this so you get


rs.FindFirst "[Surname] = " & chr(34) & nz([Text185], "") & chr(34)

note also that as text185 is text, the nz result must also be text, rather than zero as you had.

in fact maybe you ought to test for a valid string

Code:
if nz(text185,"")="" then
    msgbox("No search string")
    exit sub
else
[B]    rs.FindFirst "[Surname] = " & chr(34) & [Text185] & chr(34)[/B]
[B]    etc[/B]
end if
 

Pavczech

Registered User.
Local time
Today, 09:45
Joined
Jul 11, 2012
Messages
41
Hi ya

i have just putted it in quotatins and took some out it works

rs.FindFirst "[Surname] = '" & Me![Text185]&"'"


Thanks for your reply
 

Users who are viewing this thread

Top Bottom