By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,091 Members | 1,917 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,091 IT Pros & Developers. It's quick & easy.

Prevent command buttons click while one process

P: 3

I have an access form with command buttons. My problem is while executing one command button's process the users are able to click and execute other command buttons also. I tried hourglass on but it shows the green circle mouse pointer, but if I click any other command button then that code is also executes.
Can anyone tell me how to stop or freeze other command buttons code execution while one process is going on?
Thank you all
Mar 11 '14 #1
Share this Question
Share on Google+
5 Replies

Seth Schrock
Expert 2.5K+
P: 2,941
You could disable the other buttons at the beginning of your code and then re-enable them at the end. This however shouldn't be necessary as Access can only run one set of code at a time. What exactly is happening that makes it seem like it is running both at the same time?
Mar 11 '14 #2

P: 3
actaully one button is importing some text files to a table. If I try to click the other buttons while the import process going on then that process also starts (like if a button suppose to create an excel file that is also happening. I want to prevent all other code executions when one process starts. Any help would be appreciated. I am looking for an event in the details section of the form which can prevent any other clicks till the on going code execution finishes
Mar 11 '14 #3

Seth Schrock
Expert 2.5K+
P: 2,941
About the only thing that I know of that would work would be to set Enable = False on any controls that have On_Click or On_DblClick events at the beginning of your button's On_Click event. You can then set Enable = True on those controls at the end of the event. So, for your button that imports the text files you would have
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdImportFile_Click()
  2. Me.cmdCreateExcelFile.Enabled = False
  4. 'Your code to import the text file
  5. '...
  7. Me.cmdCreateExcelFile.Enabled = True
  8. End Sub
Mar 11 '14 #4

Expert Mod 15k+
P: 31,494
Good answer Seth.

Another one would be to set a Public Boolean variable when your code is running and reset it at the end. All entry points from the operator could then check this value and exit immediately if set (True).
Mar 12 '14 #5

P: 3
Thank you all. I will give it a try and reply
Mar 12 '14 #6

Post your reply

Sign in to post your reply or Sign up for a free account.