running queries in code

B

Bill

I'm used to opening recordsets in code by passing
the SQL query as a character string. E.g.,
rsMyset.open "Select bla bla bla"
What's the syntax if one wants to run an established
query by specifying the name of the query? The help
text I see suggests that the use of Query("QMyQuery")
is outdated, so I'm in mystery.

Thanks,
Bill
 
D

David W. Fenton

I'm used to opening recordsets in code by passing
the SQL query as a character string. E.g.,
rsMyset.open "Select bla bla bla"
What's the syntax if one wants to run an established
query by specifying the name of the query? The help
text I see suggests that the use of Query("QMyQuery")
is outdated, so I'm in mystery.

Looks like you are using ADO, rather than the more natural DAO.

In DAO, a query or table name by itself is as valid as a SQL SELECT
statement, but I don't know about ADO, which I never use.

In other words, both of these are valid in DAO:

Set db = CurrentDB.OpenRecordset("MyQuery")

Set db = CurrentDB.OpenRecordset("MyTable")
 
B

Bill

Yes, I shoot a hole in my foot every time I get the methods
of ADO and DAO intermixed in my head. I started out
mislead quite some time ago using ADO and haven't
got it completely out of my mind............what's left of it.
Thanks,
Bill
 

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