well, if that's the entire SQL string, and if you copied it directly from
your code module, you have two problems. first, it's not a complete SQL
statement, and second, it's not a complete string. suggest you build the
query in query design view first, then change the SQL View and copy the SQL
statement, and paste that into the code window. then you need to put the
statement into strings, and properly concatenate them. use the following
example as a guide:
STRSQL = "SELECT FirstName, LastName, BirthDate, " _
& "EmpCode FROM tblEmployees WHERE FirstName = '" _
& Me!txtFirstName & "' And Birthdate = #" _
& Me!txtBirthDate & "# And EmpCode = " & Me!txtCode
in the above example, the FirstName field is a Text data type (in the
table) - note the reference to the txtFirstName control on the form is
surrounded by single quotes. the BirthDate field is a Date/Time data type,
so the control reference is surrounded by the # sign. and the EmpCode is a
Number data type, so that control reference is not surrounded by anything.
hth
Vivista Eastbourne said:
I tried the following query in my vba:
STRSQL = lstSelectFrom >= txtSearchParameter11 & " AND " &
lstSelectFrom]
<
& txtSearchParameter21 & ";"
DoCmd.RunSQL STRSQL
but nothing happens, any ideas why this would not be valid?
lstSelectFrom is a listbox
txtSearchParameter11 and txtSearchParameter21 are the date range boxes
Thanks