button colour

rupes_mahal

Registered User.
Local time
Today, 23:08
Joined
Aug 12, 2001
Messages
60
hi..

I want to know if i can change the colour of a command button. It always stays grey. I can change the colour of the text on the button, but not the background of it.

Thank you in advance
ruby
 
I don't think you can. However, you can create a label (instead of a command button) and put your code or macro name in the OnClick event and it works the same way. Then you have complete flexibility with colors.
 
shacket...

thank you for your idea, it works.

ruby
 
Well all-be! I've wanted to know that for a long time! Great!
 
You can also add this to a labels event to simulate pushing the button.
Private Sub Label0_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Me.Label0.SpecialEffect = 2
End Sub

Private Sub Label0_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Me.Label0.SpecialEffect = 1
End Sub

This way it looks like a button when you push it.
 
Hi.

I came across someone with a free example of how to do this changing color of command button.

E-mail me if you want a copy of it.

Russ
 
I'm using the label-as-button technique successfully, but be aware that if your form view is "continuous forms" and you have one of these label-buttons on each line, clicking the button does NOT make the row containing the label you click the current row. For example, if you wanted to have a label with an "X" in it to delete the record, and the focus was on a different record, the record containing the focus would be deleted, not the record in the row you click.

You can overcome this problem by using an unbounded text box instead of a label, but then the cursor changes shape when you hover over it. Too bad MS couldn't just give us a background and foreground color for command buttons.

Sorry for the jumbled syntax...it's nearly bedtime.

Jim
 
The other way to do it is a command button with the visible property set to No and put a coloured label behind it. Then you get the full range of commands
 
Here's how I did it:

Put the label on, set your color. Size a command button to fit on the label. Sets it's events and then set its property: Transparent: Yes

and Visible should be: Yes

If you set visible to no. Nothing will happen when you click.

Too cool! Now we can have all the colors of the rainbow UNTIL MS gives us command button colors!
 

Users who are viewing this thread

Back
Top Bottom