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

Button color

Status
Not open for further replies.

pbrown77

Technical User
Feb 21, 2005
55
US
Okay...
With everything that can be done in Access, where do you change the background color of the buttons?

Or do I need to make a button picture in a diffent program?
 
The only thing that I know you can do is make a bmp or ico file and use that as the image for the button. I have not seen it possible to change the color.

I know, I agree with you.

misscrf

It is never too late to become what you could have been ~ George Eliot
 
Re ability to change button color, that's one of my biggest complaints :(

Depending on how bad I want the color, I sometimes substitute a TEXT box for the command button, add a little flavor, use the Click event, stir for a while...

35+ years of 'progress' -- can't we all just go wire boards again?
 
Hi!

Go to this site:


and click on the contents. You will be able to find an Access Db that will include code that will change the back color of a button. It will also include code that will rotate the text on a button.

Plus, there are many more Dbs

hth


Jeff Bridgham
Purdue University
Graduate School
Data Analyst
 
Hi,

I have been able to accomplish changing the button colour the following way.

First I create 2 different colour images of the button and place them ontop of each other. What we do now is alter the visability of the 2 button as the mouse moves over them, giving the effect of the button changing colour.

You also need to name the 2 images differently. In my example below they are called "cmdReset" and "cmdResetGrn". This is done in the properties --> other --> name field.


On the top button go into the property --> event section and create an [event procedure] for the "On Mouse Move" section. The code to add is:

Me!cmdReset.Visible = False
Me!cmdResetGrn.Visible = True

This makes the top image now not visible and the image underneath now visible - giving the illusion of a button colour change.

While in the visuale basic editor also add the following function:

Function fUnTweakImage()
Me!cmdResetGrn.Visible = False
Me!cmdReset.Visible = True
End Function

This function reverses what we have done above, as the cursor moves back off the button it changes back.

Now add a call to a function:

Go to the area that the buttons sit (not the buttons) and right click --> properties --> event --> On Mouse Move field add the call:

=fUnTweakImage()

Now as you move the cursor on and off the button it changes colour. If you have any questions or want an example I can forward something to you.

Cheers.
 
The simplest way to do this, using the least resources, is:

1) Make a Label with the colors and caption you desire.

2) Move it so that it aligns and slightly overlaps your
comand button.

3) Select your command button and set it's Transparent
Property to "Yes"

4) Select your command button and on the menu bar select
Format. Click on Bring to Front.

5) Move your Label and adjust its size so it completely
aligns with the command button.

6) You're good to go.

The Missinglinq

There's ALWAYS more than one way to skin a cat!
 
Completely agree with label stuff, but why have a command button at all? Unattached labels expose some events that make them excellent "command buttons", without adding costly graphical elements.

Just alter the Special Effect property of the label to "Raised", then add the following in the MouseDown event:

[tt]me!lblMyLabelButton.specialeffect = 2 ' sunken[/tt]

and the following in the MouseUp event:

[tt]me!lblMyLabelButton.specialeffect = 1 ' back to raised[/tt]

These events would then probably also fit well with the colourstuff, I should think...

Roy-Vidar
 
Hi, Roy,

I concur with your thoughts; however, there are some specific reasons one might want a transparent button:
1) a label control cannot gain focus
2) a button's click speed is different from a label's, i.e. 2 clicks at a rate that would be interpreted by a label as a double-click are interpreted by the button as 2 single clicks.

I think we talked about this in another thread a while back when I was designing a custom calendar form. I wanted the aesthetic flexibility of a label but needed the functionality of a command button and the label/transparent button trick was just the ticket.

But... for most cases I think your comments re: label vs. button are on the mark.

Ken S.
 
Eupher - you use both the click and double click event of the same control? Doesn't both event always fire when doubleclicked? If so - how do you separate them?

And, the mousedown event, could perhaps also be used to stuff the name/index of a control (label?) into a public variable for later retrieval?

Bit off, though, with regards to the colour of buttons [tongue]

Roy-Vidar
 
Another argument for using a command button, as opposed to the click events of a label, is that a couple of years down the road, when modifications need to be made to the db, it might not be the same person doing the work. Someone else coming in will be looking for a command button to carry out a command. Heck, it might even be you, and you could be looking for a command button! It's the same reason we all (well, most of us) name command buttons cmdMyCommand instead of simply MyCommand. Both work, but the former is easier for everyone to identify.

Just my 2 cents worth! As my signature tag says:

There's ALWAYS more than one way to skin a cat!

The Missinglinq

There's ALWAYS more than one way to skin a cat!
 
Roy,

You're right, we're wandering a bit off-topic, but... ;-)

No, I don't use both the click and double-click events. But on a button the user may click much quicker and it's still interpreted as a single click; whereas with the label, the same rate of clicking would be interpreted as a double-click; and since there's no code on the double-click event, the second click just gets thrown away.

Ken S.
 
Ok - now I understand what you mean.

I guess I've never reflected about it, cause when toggling the special effect, there's no visual "button pressing" on the screen when the too hasty second click is issued - so there's no visual confirmation that anything is going to happen - one might perhaps say some consistency in the inconsistency?.

Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top