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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I changing a VBA command button color w/out re-opening form?

Status
Not open for further replies.

PicketOaks

Technical User
Nov 3, 2010
2
US
Hi -

I would like to know how to refresh a form after using a command button. That is, I created a command button that evokes a comment box. After I enter in a comment I would like to change the color of the button right away. For now, I need to close the form and reopen it for color change to show.

Any help here is greatly appreciated. Please note I'm not a professional programmer (yet) so will need a somewhat explict example.

Thanks in advance!
 
Private Sub CommandButton1_Click()
CommandButton1.BackColor = RGB(1, 1, 200)
End Sub
 

or:
Code:
Option Explicit

Private Sub CommandButton1_Click()
CommandButton1.BackColor = vbButtonFace
End Sub

Private Sub UserForm_Click()
CommandButton1.BackColor = vbYellow
End Sub

Have fun.

---- Andy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top