From: paul bennett on
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?
From: Jeff Boyce on
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.

"paul bennett" <paulbennett(a)discussions.microsoft.com> wrote in message
news:D559C11F-0919-40D9-8323-D5F1B8D45471(a)microsoft.com...
>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?


From: Stuart McCall on
"paul bennett" <paulbennett(a)discussions.microsoft.com> wrote in message
news:D559C11F-0919-40D9-8323-D5F1B8D45471(a)microsoft.com...
>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"