Changing a picture on a CMD button after click

M

Matt

I am trying to find the code that will automatically change the picture on my
command button after I click on it. I basically want an up arrow and down
arrow to change back and forth after each click.

Also, If the answer is setting the picture property how do you find out the
code ID for each picture, right now the property only reads (bitmap).

Thanks,
Matt
 
A

Allen Browne

Yes, you could set the Picture property of the command button in its Click
event.

An easier approach would be to set the Caption property:

1. In form design view, right-click the command button, and choose
Properties.

2. Set the Font Name to:
WingDings.

3. Select the Caption property (Format tab of Properties box).

4. Hold down the Alt key, type 0241 on the numeric keypad, and then release
Alt. This gives you the up arrow character.

5. Set the On Click property (Events tab) to:
[Event Procedure]

6. Click the Build button (...) beside this.
Access opens the code window.

7. Between the "Private Sub ..." and "End Sub" lines, paste this:
With Me.[Command1]
If .Caption = Chr(242) Then
.Caption = Chr(241)
Else
.Caption = Chr(242)
End If
End With

8. Replace "Command1" with the name of your button.
 
M

[MVP] S.Clark

It may not be Ideal, but you could have two buttons, one with each pic.
Turn on & off the visibility when clicked.

Another hack would be to place an Image control instead of cmd button.
There you can switch the picture property.
 
Top