0

Good day guys.

I want want a little help of my query.

The tbl_ entity:
tbl_1(UserId(AutoNum
ber - set as primary key),Validity(Date/Time))

dim logonid as long

rs.open "SELECT * FROM tbl_1 WHERE UserId='" & logonid & "'",conn, adopenkeyset,adlockoptimistic

It returns an error invalid data type expression. But when i changed the UserId datatype to Text it will works..Whats wrong with the AutoNumber datatype?

Ex. if logonid has a value of 2, even if the value is in the database it returns the error invalid data type expression.
Thank you guys for giving time.

Edited by blocker: n/a

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by blocker
0

Your going to go D'oh here in a moment :) ...

An autonumber is a number and not text so when quering against a number you do not wrap it with single ticks (')...

Good Luck

0

Your going to go D'oh here in a moment :) ...

An autonumber is a number and not text so when quering against a number you do not wrap it with single ticks (')...

Good Luck

so what should should i do since longid is a variable waht declared as long.

what should i replaced with this code

dim logonid as long rs.open "SELECT * FROM tbl_1 WHERE UserId='" & logonid & "'",conn, adopenkeyset,adlockoptimistic

Thank you Guys. God bless.

I think i got it. This might be the correct way.

dim logonid as long rs.open "SELECT * FROM tbl_1 WHERE UserId=" & logonid ",conn, adopenkeyset,adlockoptimistic

Thank you guys.

Edited by blocker: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.