Command button running a query returns error

T

Tom McMillion

I created a new command button on a form using the
following procedure to run a parameter query:

In form design view, clicked on Command Button on the
Toolbox. Then clicked in the design grid to place the
button. Chose category: Miscellaneous Actions: Run
Query. Chose the Query to be run.

This simple query has a prompt telling the user to enter
the customer ID to search for, then looks up that
customer from a simple two-field customer table. This
query runs fine by itself, but the query will not run
from the command button. The following error message is
returned:

"The expression On Click you entered as the event
property setting produced the following error: Invalid
outside procedure

* The expression may not result in the name of a macro,
the name of a user-defined function, or [Event Procedure].
* There may have been an error evaluating the function,
event, or macro."

Any thoughts? Seems so simple that it ought to work but
it doesn't.
 
T

Tom McMillion

Thanks Chas.

Actually it's a query I'm trying to launch from a command
button. That doesn't work and returns the error message
I listed in my previous message.

If I try to use a MACRO to open the query, that works but
only as long as you don't click the "Cancel" button on
the dialog box that opens when running the query. The
dialog box is for the purpose of the user entering the ID
of the customer he or she is looking for.

If you click Cancel on the dialog box rather than OK, an
error message is returned which is entirely different
from the one I've described here, where I'm trying to use
a command button to launch a QUERY directly. The macro
error message is one of those popup windows that has a
Halt button.

Bottom line is I can't launch a query directly from a
command button using the built-in commands, nor can I
launch a query by means of a macro as an intermediate
step, using the built-in commands. This is my dilemna at
this stage.

And I'm not a VBA programmer at all, although I see the
need to learn at this point.

I am hoping someone can offer some VBA code to help,
since I've tried using the built-in commands with proper
naming conventions and everything, to no avail.

Thanks for your reply.
 

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