Selectively running macros/queries

John P

Board Regular
Joined
Oct 17, 2002
Messages
108
My database consists of a few tables, numerous queries and one macro to run all queries. Each month I import the most recent month data and run the macro. In my inefficient world, the macro runs against all months, instead of just the most recent, so it can take up to 15 minutes to complete.

I would prefer that when I select to run my macro, it allows me to select the reporting month (this is a field on my main table that is updated with the queries) or reporting months I wish to have the macro run against. Is this possible without a major overhaul to the existing DB? Any suggestions are appreciated. Thanks
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Put a paramater on the month field in your Criteria for that field.

For example, open your query in Design View. In the month field, under criteria enter:
[Enter your month]

Now any time you open this query, it will prompt you to enter the month and will limit your query to those results. If you run the macro off of this query, it will prompt you for the month every time.

See Access help for "Create a parameter query" for more details, if necessary.
 
Upvote 0
If several of my queries do not currently contain reporting month as part of the query, can I simply add reporting month to the query and click do not show? Also, if I have 30 queries, won't the application prompt me to enter this value 30 times? Lastly, if I set warnings to off, will I still be prompted?
 
Upvote 0
You don't need to add it to all your queries, just the ones where you want to filter out all unnecessary months. It sounds like this may be a very big and involved job you got running there.

Can you connect and link a bunch of queries together to limit the number that your macro accesses when it runs? A bettter solution may be creating a user form to enter selection criteria and then writing VBA code to create SQL statements to do what your macro is accomplishing. As you can imagine, that is it a bit more complicated (especially if you haven't written much VBA code before).
 
Upvote 0

Forum statistics

Threads
1,221,623
Messages
6,160,889
Members
451,676
Latest member
Assy Bissy

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