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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top