By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,731 Members | 1,123 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,731 IT Pros & Developers. It's quick & easy.

VBA code false "rst.FindFist strSearch"

P: n/a
Dear reader,

I have the following code:

StrSearch = "[Employee_code] = " & strUser & ""

Employee_code is a text field with a numeric value like 41001

strUser has also a numeric value.

The next code results in an error message

Rst.FindFirst strSearch

The error message is "Data type mismatch in criteria expression".

How can I force that both are of the same data type.

Thanks for any help,

Simon
Oct 19 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a

Simon wrote:
Dear reader,

I have the following code:

StrSearch = "[Employee_code] = " & strUser & ""

Employee_code is a text field with a numeric value like 41001
CONST cQUOTE As String = "'" '(single quote within double quotes)

strSearch = '[Employee_code] = cQUOTE & strUser & cQUOTE

Oct 19 '06 #2

P: n/a
"Simon" <Sv********@Versatel.nlwrote in message
<45***********************@news.tele2.nl>:
Dear reader,

I have the following code:

StrSearch = "[Employee_code] = " & strUser & ""

Employee_code is a text field with a numeric value like 41001

strUser has also a numeric value.

The next code results in an error message

Rst.FindFirst strSearch

The error message is "Data type mismatch in criteria expression".

How can I force that both are of the same data type.

Thanks for any help,

Simon
Criterion on text fields need text delimiters. Try;

StrSearch = "[Employee_code] = '" & strUser & "'"

--
Roy-Vidar
Oct 19 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.