Full Version: button change color when clicked
UtterAccess Forums > Microsoft® Access > Access Forms
I have a button that i applied an image to it. When the button/image is clicked i would like it to change change images. Is this possible?
Thank you
Using the OnClick event of the command button you can do something like this:
If Me.MyCommandButton.Picture = "C:\MyFullFilePath\Picture 1.bmp" Then
    Me.Command33.Picture = "C:\MyFullFilePath\Picture 2.bmp"
   Me.Command33.Picture = "C:\MyFullFilePath\Picture 1.bmp"
End If
Do you want the button to remain displaying the second image after clicked - meaning each click would alternate between images.
If you want the image to be displayed only during the click-down portion of the button click, then use :
On Mouse Down event - Me.Command33.Picture = "C:\MyFullFilePath\Picture 2.bmp"
On Mouse Up event - Me.Command33.Picture = "C:\MyFullFilePath\Picture 1.bmp"
hope this helps
The plan is for it to alternate between images when clicked. This way we can determine if someone is in the building or not by just looking at the color (red = out, green = in).
Just curious . . . why not use a toggle button instead of a command button?
This plan is to put this DB on a win7 pad which i'll put at the back door where all the employees enter/leave. I think the button will be easier to touch versus a toggle button/switch. I could be wrong thou and i might try a toggle button as it might be easier to implament.
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.