rupes_mahal
08-14-2001, 05:57 AM
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
shacket
08-14-2001, 07:33 AM
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.
rupes_mahal
08-14-2001, 07:57 AM
shacket...
thank you for your idea, it works.
ruby
jwindon
08-14-2001, 10:54 AM
Well all-be! I've wanted to know that for a long time! Great!
Zorro
08-24-2001, 11:23 AM
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.
russi
08-27-2001, 11:07 AM
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
jimbrooking
08-31-2001, 04:54 PM
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
D B Lawson
09-01-2001, 11:08 AM
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
jwindon
09-01-2001, 11:34 AM
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!