I can't figure out what is wrong in this,
I'm collecting search criteria from a Form to use it in search.
The SQL line stored like this : (strWhere is the collected info from the Form)
SQLst = "SELECT Deposits.Fines, Deposits.[Deposit Value], Deposits.[Deposit Date], Deposits.Depositor, Info.Tower, Deposits.[Account Number] FROM Info, Deposits Where " & strWhere & ";"
The final SQL statement looks like this:
SELECT Deposits.Fines, Deposits.[Deposit Value], Deposits.[Deposit Date], Deposits.Depositor, Info.Tower, Deposits.[Account Number] FROM Info, Deposits Where ([Account Number] = "1234");
Now After I run the Line using this command (SQLst is the SQL Line up)
DoCmd.OpenQuery SQLst
I get this message:
Best Answer
Not
DoCmd.OpenQuery SQLst
, that is for saved queries, not SQL strings. You need:For action queries:
For SELECT queries, you can either use a recordset or update or create a query.
I doubt that the account number is text, so:
Quotes are used for text-type fields / columns, numbers are as is and dates are delimited with hash (#).