formatting backcolor on Forms Control Button

D

daniel

I was curious how you could color the backcolor of a forms button using VBA.
The default is Grey, I would like to color it another color.

Thanks
 
J

John Bundy

You can use RGB, scales are available online if you want a particular color.
CommandButton1.BackColor = RGB(0, 0, 100)
 
J

John Bundy

You can also play with the color to get it the way you want it in properties,
then copy the backcolor you like, switch back and then
CommandButton1.BackColor = &H80000012
 
D

daniel

John
Thanks for your response. Forgive me if I am misunderstanding (I am a
novice)but here is the code I tried.
Sub Button3_Click()

CommandButton3.BackColor = RGB(0, 0, 100)
End Sub
It didn't change the back color on the button. What am I doing wrong?
 
J

John Bundy

ok, by the look of your Sub you just wrote that on your own. if you
doubleclick on the button in design mode it should create the Sub for you
that will look like
Private Sub CommandButton3_Click()

otherwise you can go to the IDE (where you type the code) and you should see
two drop down menu's, click the left one and select CommandButton3, the right
combobox should automatically populate with Click and you should see this
Private Sub CommandButton3_Click()

End Sub

add your code in there like this

Private Sub CommandButton3_Click()
CommandButton3.BackColor = RGB(0, 0, 100)
End Sub
let me know if you still have trouble
 

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

Top