A
Al
I have a query statement that runs off of the users input in a textbox on a
form. The input is placed in "Var1" and used in a SQL string shown below.
The Append in the string is used to combine two informational fields in the
source table, Project Name and Project Description; to help increase the hits
on the user's search input.
The query runs fine in the QBE grid; however, I am trying to move it into
VBA code and create a multiple query option form. The problem I'm running
into with this code is with the double quotes inside the query. I keep
getting a Compile Error: Expected: end of statement. I tried using Chr$()
values throughout the statement but I couldn't get that to work either. I
know this can be done, I'm just not getting the syntax correct. Any help
would be greatly appreciated.
SelSQL = "SELECT AllProjects.Project, AllProjects.[Brief Description],
AllProjects.Code, [Project] & " " & [Brief Description] AS Append
FROM AllProjects
WHERE ((([Project] & " " & [Brief Description]) Like "*" &
[forms]![frmSearch1]![Var1] & "*"))"
Thanks,
Al
form. The input is placed in "Var1" and used in a SQL string shown below.
The Append in the string is used to combine two informational fields in the
source table, Project Name and Project Description; to help increase the hits
on the user's search input.
The query runs fine in the QBE grid; however, I am trying to move it into
VBA code and create a multiple query option form. The problem I'm running
into with this code is with the double quotes inside the query. I keep
getting a Compile Error: Expected: end of statement. I tried using Chr$()
values throughout the statement but I couldn't get that to work either. I
know this can be done, I'm just not getting the syntax correct. Any help
would be greatly appreciated.
SelSQL = "SELECT AllProjects.Project, AllProjects.[Brief Description],
AllProjects.Code, [Project] & " " & [Brief Description] AS Append
FROM AllProjects
WHERE ((([Project] & " " & [Brief Description]) Like "*" &
[forms]![frmSearch1]![Var1] & "*"))"
Thanks,
Al