Changing a picture on a CMD button after click

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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.
 
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top