Opening a query from a command button

P

paul bennett

I have several queries opening from a single command button. The first should
be:

DoCmd.OpenQuery DELETEtbldatentry

I get an error message telling me "DELETEtbldatentry = empty"
the query name is correct (including case) and the query opens and runs fine
when opened manually.

What am I doing wrong?
 
J

Jeff Boyce

Paul

Please provide a bit more context in which this line of code is being
executed...

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.
 
S

Stuart McCall

paul bennett said:
I have several queries opening from a single command button. The first
should
be:

DoCmd.OpenQuery DELETEtbldatentry

I get an error message telling me "DELETEtbldatentry = empty"
the query name is correct (including case) and the query opens and runs
fine
when opened manually.

What am I doing wrong?

Because DELETEtbldatentry is the name of a query, VBA just interprets it as
a string of characters (which it is) and incorrectly assumes it's a
variable. You need to surround it with quote marks so VBA can interpret it
as the name of a query, which is what OpenQuery is expecting.

DoCmd.OpenQuery "DELETEtbldatentry"
 

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