Open Query based SQL statement

J

Jose Perdigao

How can I open a query based a SQL statement?

I tried the following code but doesn't work.
dim strSQL as String
strSQL = "SELECT A2_WOUnitN.* FROM A2_WOUnitN;"
DoCmd.OpenQuery strSQL

I know, I can create a query based sql statement and then open the query. Is
it possible open the query directly from sql statement ?

Thanks a lot,
Any suggestions?

José
 
A

Allen Browne

No. The SQL string has to be assigned to something that is interfaced, such
as a QueryDef:
CurrentDb.QueryDefs("Query1").SQL = strSql
or a form:
Forms!Form1.RecordSource = strSql
 
Top