Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disabling buttons upon execution

Status
Not open for further replies.

cssilver

Technical User
Aug 6, 2000
17
US
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.
 
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?
 
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.
 
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
 
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.

Caroline
 
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.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top