Command Buttons

  • Thread starter Thread starter ranswrt
  • Start date Start date
R

ranswrt

How would I make a commandbutton in a form 'enable=False' whenever another
commandbutton 'enable=True'?
 
Hi Ranswrt,

You have not indicated how the first
CommandButton is enabled or disabled,
but try something like:

Me.CommandButton2.Enabled = _
Not Me.CommandButton1.Enabled = True

Perhaps it would be possible to provide
more specific help if you were to explain
the enabling mechanism or the purpose
of the excercise.
 
I turn the buttons on and off with different procedures on the userform. i
was wondering in there was an event procedure that would make sure that only
one button was on at a time.
 
I'd suggest you just use two subs


Private Sub Button1_On()
Me.CommandButton2.Enabled = False
Me.CommandButton1.Enabled = True
End Sub

Private Sub Button2_On()
Me.CommandButton1.Enabled = False
Me.CommandButton2.Enabled = True
End Sub

that you call from the "different procedures", e.g.:

Private Sub UserForm_Initialize()
'Stuff here
Button1_On
End Sub

Private Sub CommandButton1_Click()
'Do more stuff
Button2_On
End Sub

Private Sub CommandButton2_Click()
'Do even more stuff
Button1_On
End Sub
 
Thanks i think that will work

JE McGimpsey said:
I'd suggest you just use two subs


Private Sub Button1_On()
Me.CommandButton2.Enabled = False
Me.CommandButton1.Enabled = True
End Sub

Private Sub Button2_On()
Me.CommandButton1.Enabled = False
Me.CommandButton2.Enabled = True
End Sub

that you call from the "different procedures", e.g.:

Private Sub UserForm_Initialize()
'Stuff here
Button1_On
End Sub

Private Sub CommandButton1_Click()
'Do more stuff
Button2_On
End Sub

Private Sub CommandButton2_Click()
'Do even more stuff
Button1_On
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top