Click to See Complete Forum and Search --> : Access VBA SQL Listbox


mojo
July 21st, 1999, 09:55 PM
I'm writing some Access VBA code (DAO) for work and I want to pass the
value the user selects in a listbox to a SQL statement (using a query).
I tried this code:

....
[querydef name]. SQL = "SELECT * FROM TBL_Contacts & _
WHERE Country = '"lstCountry.Text"'"
It doesn't work though--that Access "Query Parameters" dialog box pops
up instead.
I feel silly asking this since I'm sure there must be a simple solution,
but I haven't been able to figure it out.. I also tried putting two sets
of double quotes around lstCountry.Text, but that didn't work either.

Lothar Haensler
July 22nd, 1999, 01:33 AM
imho it should look like this:

[querydef name]. SQL = "SELECT * FROM TBL_Contacts " & _
"WHERE Country = '" & lstCountry.Text & "'"