Correct syntax using a numeric variable in the WHERE clause

G

GMann

Hi;

How do I get a numeric variable's stored value to be interpreted correctly
in a SELECT / WHERE ?

For example :

Dim x as integer = 1

SELECT * FROM aTable WHERE aColumn = x.

If aColumn is a numeric column in an Access table what "other" characters do
I need to enclose the x in to have the select statement to be correctly
interpreted ?

I know that for a string in Access you must enclose the variable in quotes
like :
SELECT * FROM aTABLE WHERE aSTRINGCOLUMN = ' " & string variable & " '.

Thanks
 
F

fredg

Hi;

How do I get a numeric variable's stored value to be interpreted correctly
in a SELECT / WHERE ?

For example :

Dim x as integer = 1

SELECT * FROM aTable WHERE aColumn = x.

If aColumn is a numeric column in an Access table what "other" characters do
I need to enclose the x in to have the select statement to be correctly
interpreted ?

I know that for a string in Access you must enclose the variable in quotes
like :
SELECT * FROM aTABLE WHERE aSTRINGCOLUMN = ' " & string variable & " '.

Thanks

"SELECT * FROM aTable WHERE aColumn = " & x

and you are missing a final " in your string syntax statement.
..... aSTRINGCOLUMN = ' " & string variable & " ' ".
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top