I prefer to write my queries in code, but I am not sure how to reference them from another query. I know FoxPro supports cursors, but Is this possible in Access?
As Jerry said ... but with a bit of elaboration ...
Just writing and running some SQL in code doesn't make it a "query" in the Access sense. To make it something that you can reference in another query you must append it to Access's QueryDefs collection. Something like this
Code:
Dim SQL As String
SQL = "Select * From TheTable Where fld1 < 99"
CurrentDb.CreateQueryDef("myQuery", SQL)
Then you can refer to "myQuery" in other queries just as you would a table.
The above example is DAO and there are equivalent mechanisms in ADO. There you will append the query to an ADOX Catalog.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.