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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
Thomas SwaneyOwnerCommented:
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

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
Thomas SwaneyOwnerCommented:
For example formbutton1.Enabled = True
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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 ArchibaldCommented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.