How to only allow 1 button to be pressed at a time

bradyboyy88

Well-known Member
Joined
Feb 25, 2015
Messages
562
So I have a few different buttons in a modeless vba form Each of these buttons runs ado queries on an access database. My issue is that 1 button can be pressed and while its still running and loading the query data another button can be pressed which tries to run another query. Is there anyway to only allow 1 button to be pressed or executed at time? Or make the macros go in order so when the one buttons macros are finished the next one would go right after?
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
1. You can disable other buttons at the start of click event of clicked button and then re-enable them at the end.
2. Keep a form level variable to check if a button click event is still running. Check the variable's value in each button's click to determine if it should be run.
3. If queries are supposed to be executed in order, then you can either hide/unhide buttons, or use a single button with updating caption, or use a multi-form design.
 
Upvote 0

Forum statistics

Threads
1,224,826
Messages
6,181,192
Members
453,021
Latest member
pingpong7117

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