SQL in VBA

D

Dan

I was wondering if you can do anything use any SQL statement here:

stLinkCriteria = "SELECT * FROM [Customer Profile Sheet] WHERE [race] IN
(""Asian"", ""Caucasian"")"

DoCmd.OpenForm stDocName, , , stLinkCriteria

I wrote a query that said:
"SELECT *
FROM [Customer Profile Sheet]
WHERE [race] IN ("Asian", "Caucasian")"

and that worked fine so if I can do in VBA this that would be awsome or is
there another way. I know you could use the the OR statement but this is
actually only a small portion of the SQL statement that I need. Thanks
 
D

Dan

Sorry I was not thinking. I know what I was doing wrong. Just incase anyone
else was wondering here is what I should have done:

stLinkCriteria = "[race] IN (""Asian"", ""Hispanic"")"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Any Suggestions for a better way?
 
J

John Vinson

Sorry I was not thinking. I know what I was doing wrong. Just incase anyone
else was wondering here is what I should have done:

stLinkCriteria = "[race] IN (""Asian"", ""Hispanic"")"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Any Suggestions for a better way?

You can actually simplify it a bit by using the alternative '
delimiter for text strings. Provided your field values don't
themselves contain apostrophes, anyway!

stLinkCriteria = "[Race] IN ('Asian', 'Hispanic')"

John W. Vinson[MVP]
 
Top