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.

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

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.