Protect a form button from repeated activation.

Hello Experts, I have a button that is starting a macro. Button works perfectly but if someone presses it a second time then the macro is running a duplicate. How could this be avoided? Thank you ahead of time.
fun_gAsked:
Who is Participating?
 
Thomas SwaneyConnect With a Mentor OwnerCommented:
For example formbutton1.Enabled = True
0
 
Thomas SwaneyOwnerCommented:
Can you disable the button and then enable the button after running the code?
0
 
fun_gAuthor Commented:
This is exactly what I would like to do but I have no idea how to disable a form button.
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
Thomas SwaneyOwnerCommented:
0
 
fun_gAuthor Commented:
Any chance that you could post the info here. I have tried this link you provided plus I have tried connecting to OZGRID.com for the past few weeks with only failed attempts.  I have retried just now and there is no connection to the server.
0
 
Thomas SwaneyOwnerCommented:
I would like to but I don't want to post information from another site. I think that would probably violate the rules or something. I would be glad to email you a word document of the page if you would like. Is there a way that I can get your email address?
0
 
Thomas SwaneyOwnerCommented:
I have attached a PDF of the thread.
http---www.ozgrid.com-forum-prin.pdf
0
 
fun_gAuthor Commented:
Wow that was a great pdf link, thank you. Problem is that the buttons in question are called "form" buttons found in the forms toolbar and the buttons being address in the ozgrid links are command buttons found in the Control Toolbox. Does this mean that I will have to change all of my form buttons into command buttons?
0
 
Thomas SwaneyOwnerCommented:
Can you reference the form buttons like they are referencing the command buttons?
0
 
fun_gAuthor Commented:
Excellent! I am sorry to show my lack of knowledge but how do I find the name or number of a form button?
0
 
Rory ArchibaldConnect With a Mentor Commented:
If you right click a button from the Forms toolbar (I assume you mean on a worksheet), you should see its name in the Name box just above the column A header. You can then use:
activesheet.buttons("Button 3").enabled = false

alternatively, if you are calling the same macro from several buttons, you can use:
   ActiveSheet.Shapes(Application.Caller).OLEFormat.Object.Enabled = False
which will disable whichever one you clicked on. Don't forget to re-enable it as required!

Regards,
Rory
0
 
Rory ArchibaldCommented:
PS You can also shorten the second one to:
ActiveSheet.Buttons(Application.Caller).Enabled = False
if you only call the macro from forms buttons, rather than any other type of control.
FWIW
0
 
fun_gAuthor Commented:
Thank you both for your help. Rory Thank you for coming through and finishing off another one for me. Great answer!
0
 
Thomas SwaneyOwnerCommented:
Your very welcome and I am glad that I could be of help to you.
0
All Courses

From novice to tech pro — start learning today.