Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Disabling buttons upon execution

Disabling buttons upon execution

Disabling buttons upon execution

I have a form with 5 buttons.  The user must click those buttons in order - for example, they will mess things up if they click button 2 before button 1, or if they click button 1 twice.  I'd like to disable the button upon successful execution of the macro called when the button is clicked.  
I tried disabling the button in the ONCLICK macro, but it appears I can't do that.  I don't think that I should do that anyway, because each time my application is restarted, the first button is enabled and the others disabled (as I set them in the form properties)- what I really want is a variable or something to hold the users place in the cycle of buttons.

RE: Disabling buttons upon execution

This is a totally different approach, but what if you only have ONE button and change the caption on it as the user clicks on it.  You could use a static variable to hold the user's state in the process.

Does that sound like something you would want to do?


RE: Disabling buttons upon execution

First, turn off the Visibile property of all the buttons but the first one.  In the OnClick of the first, you turn the next one Visible, move the focus to it (or somewhere else) with SetFocus, and finally set the first button's Visible property to False.  In other words, always restrict the users as much as you can (so they don't go astray) by limiting their choices.

RE: Disabling buttons upon execution

That's what I'm trying to do.  I suppose that before I disable the button, I have to set the focus to the next button.  I'll try that.  Thanks

RE: Disabling buttons upon execution

Also, Kathryn - I'd rather use 5 buttons - I think in this case it will be less confusing, because the users will see exactly where they are in the process.  
Can you tell me specifically how to use a static variable to keep their place?  I'm new to VBA.


RE: Disabling buttons upon execution

I quote MS itself:  "Use a Static statement within a procedure to declare the data type of a variable that retains its value between procedure calls"

Since you are going with the five button method, you will have more than one procedure, so I don't think that this will work for you.

Check out the help topic "Static Statement" for a bit more info.


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close