Using Macro to open a query, getting "Action Failed" popup

  • Thread starter Thread starter Tom McMillion
  • Start date Start date
T

Tom McMillion

I created a simple Customers table with two fields,
Customer name and Customer Number. This table will be
used to populate a Customer field on an Orders table.

I then created a form to add new customers to the
Customers table, to view all customers in the table, and
to lookup a particular customer by customer number. This
is where the problem begins. I have a "Find Customer"
button which needs to prompt the user to enter the
customer ID number. Fine, I can perform this function
well enough with a Query with a [bracketed] prompt in the
Criteria field which prompts the user to enter the
customer ID, and this query runs fine ON ITS OWN. But I
don't know how to program a button on the form to call up
this query directly.

Instead, I'm attempting to use a Macro to Open the Query.
This works fine if you enter data in the field on the
popup dialog box or leave the field blank and click OK.
But if you click on "Cancel" on the dialog box, the macro
itself causes an "Action Failed" window to open up. I
can't see what's wrong and I've looked several times and
tried to use Help to no effect.

How do I program a macro to open a query but to be able
to click cancel on the dialog box when the query runs,
without having the macro report itself report an error?
Of do I need to program the button on the form to only
use the query directly? If so, then I need to visit the
queries forum.

Thanks in advance.
 
Using a button on form to run a parameter query: In form
design view, click on Command Button on the Toolbox. Then
click in the design grid where you want the button to be.
Choose Category: Miscellaneous - Actions: Run Query.
Choose the Query to be run.
 
Back
Top