How to prevent a user from seeing the "Stop All Macros" when the enter the incorrect date format for a Parameter Query

Galapagos15

Board Regular
Joined
Sep 16, 2015
Messages
100
I have a macro which includes a parameter query. Currently, when the macro is initiated and the incorrect date format is entered for the parameter query prompt I get "Stop All Macros" error box.

I tried adding an "OnError" "Fail" step into the macro but it's not working correctly. What can I add to the macro commands so the user won't see the "Stop All Macros" box but will be reprompted to enter the correct date format?

Thanks in advance!
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
I don't think you can do that with a Macro. You would have to probably use VBA.
Instead of entering the parameters with a parameter query (which really has no controls on the input), use a Form to enter in the criteria, where you can set Data Types and add VBA code to verify valid entries before applying it to your query.
 
Upvote 0
Okay thanks. I'm not really familiar with forms so I had this set up in a macro which has multiple queries in it and one was a parameter query which then in turn generates a report for that particular timeframe. I was hoping that when that macro went through the series of queries that I could insert an action prior to the parameter query which would prompt the individual to enter the dates correctly. Thanks anyway.
 
Upvote 0
Upvote 0
You could use the macro to present a message box that informs the input format but you will still have the problem if they don't comply. If you don't have time to learn the form method (which is best) check out the input box function. At least you could use a mask with that to enforce the date format. I wonder where you are located such that users are using what must be a non-native date format for your region.
 
Upvote 0

Forum statistics

Threads
1,221,831
Messages
6,162,252
Members
451,757
Latest member
iours

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top