469,138 Members | 1,295 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,138 developers. It's quick & easy.

Prevent command buttons click while one process

3
Hello

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
5 2081
Seth Schrock
2,957 Expert 2GB
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
mjony
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
2,957 Expert 2GB
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
  3.  
  4. 'Your code to import the text file
  5. '...
  6.  
  7. Me.cmdCreateExcelFile.Enabled = True
  8. End Sub
Mar 11 '14 #4
NeoPa
32,164 Expert Mod 16PB
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
mjony
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.

Similar topics

reply views Thread by Kevin McLean | last post: by
1 post views Thread by Aravind | last post: by
8 posts views Thread by Susan Bricker | last post: by
2 posts views Thread by David A. Beck | last post: by
1 post views Thread by davesauny | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.