VBA - Control Back Color Property

pedie

Well-known Member
Joined
Apr 28, 2010
Messages
3,875
Hi, small question.... till now whenever i want to set the back color of the control i use vbblue,vbgreen etc...
Now when i check access control background it has lots of color number and while doing some research i found that we can use something like RGB(84, 1, 6) which 'm not familiar to.
If i want to use backColor #84A1C6 how do i use it in RGB way?

Thanks in advance

Code:
[/FONT]
[FONT=Courier New]Me.Label18.BackColor = RGB(84, 1, 6) '#84A1C6[/FONT]
[FONT=Courier New]
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Pedie

How exactly did you create the button?

Does it have a picture on it?

PS You can actually use vbRed instead of RGB or the Hex value for the colour.
 
Upvote 0
I didn't think you could change button colors in Access ... I might be wrong!

I just tried it on a button in Access and no effect was visible when I displayed the form (even though I could set the back color property to this, that and the other.

Pedie, you have so many more things to worry about than the color of your buttons ... grey is just fine, as long as the button can be clicked! Let's focus here. Are you learning SQL? Are you studying database design principles? Forget about whether buttons are red, green, or blue ...

Note:
specifically:

Code:
Sub Command0_Click
    Me.Command0.BackColor = vbRed
    DoCmd.Repaint '//For good measure ...
    DoEvents  '//Just to be sure ...  
End Sub

Button stubbornly looks the same ...
 
Last edited:
Upvote 0
xenou

You definitely can change the back colour(s) of a button, though in Access 2010 it's all a bit strange.

I tried earlier with a button that I'd set to one of the 'Access Theme' type things.

I put some code in it's Click event to change it to vbRed.

When I clicked it nothing seemed to happen, but when I moved away the colour changed to red.

When I moved back it changed to another colour, kind of a toggle thing maybe.

I liked it when Access was simple, when you used a wizard it created a form that was easy to change.

Now you have to Remove Layout before you can even move labels/controls about.

And don't talk to me about Multiple Items forms.:)
 
Upvote 0
Pedie, you have so many more things to worry about than the color of your buttons ... grey is just fine, as long as the button can be clicked! Let's focus here. Are you learning SQL? Are you studying database design principles? Forget about whether buttons are red, green, or blue ...


Xen, thank for answering back...yep the button color is of no imporatance no matter how it looks....

and yes, 'm learning sql[the query sql 'm referring to]...and also 'm referring to w3 link you refferred me other day. But yes 'm still in trail and error stage...

Norie, i think there is some problem in access, i tried both way even vbred and still error and .backcolor line..however thats okay...it'll still work without it happening.


Thanks again guys!!!


 
Upvote 0
Pedie

Is it definitely s command button on a form?

What happens when you delete it and add a new command button?

How are you viewing the form?

Is the form with the button a subform on another form?
 
Upvote 0
Boyd

Perhaps I'm mistaken but that doesn't really create buttons.:)
 
Upvote 0
Boyd, thank you for demo file, yes it is cool [image as button] and the mouse event....Thanks alot!:)
 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,730
Members
452,939
Latest member
WCrawford

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top