Can you mark a command box as already selected?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I was wondering if there was anyway to mark a command box as being selected
once it is clicked. I'm trying to create a training game and I don't want
trainees to select the same category twice.
 
What is a command box? Do you mean command button? You can set the Enabled
property of any control to False so it cannot be done while the control has
the focus. You will need to find a way to disable the control after it has
been clicked and lost focus. Another way to do this would be to use a static
Boolean variable to know whether the button has been used in the current
session or not. If it has not, allow the normal action; otherwise, present
an error:

Dim blnOnceOnly as Boolean

If blnOnceOnly Then
MsgBox "One Time Only"
Else
blnOnceOnly = True
'Do your normal stuff here
End If
 
blnOnceOnly has to be declared with the Static keyword if it's inside the
event procedure, or it'll be reset to False each time the code executes. The
alternative would be to declare it as a module-level variable, but there's
no need for that in this case.
 
You are correct, Douglas. My Dim statement was incorrect. In the text I
specificed static, but Dimmed it incorrectly.
 
I did mean a command button. I used the wrong wording. Thanks to the both
of you for your help.
 
Is it important to know that they came in, pressed the button, closed
the form and have now re-entered the form (and can press the button
again.?)
 
Back
Top