Images on command buttons

CAS

Registered User.
Local time
Today, 20:52
Joined
May 18, 2001
Messages
15
I currently have a form with several command buttons on it, but every time I insert an image into the button, Access automatically transforms the image's background to gray. I have several images with white background and would like to leave them thay way.

To combat the problem, I changed the form to include images with code attached to the On Click property. That works fine but with one problem: on some of the forms, these buttons are actually associated with a single record on a continuous-form displayed subform.

I have code in the On Current property of the form that needs to be executed (setting the filter of the main form's recordsource), but for some reason when the "button" with the image is clicked, Access doesn't execute the On Current code.

Any thoughts? My preferred fix is to use command buttons but with my chosen background color, but any other workaround would be okay.
 
CAS,

For what it's worth, I've played around with using other controls instead of command buttons, in part because the command buttons are so boringly GREY.

If all you want to do is execute some code when it's clicked, a text box or label works. (More about images later.) Either will let you display arbitrary text in any color scheme you like. You can set the Effect to Raised and can't tell it's appearance from a command button (unless you have made it with pretty colors).

Used on a continuous form, the Label-command-button does not move the focus to the record on which the label is located. On a continuous form, a text box does. Disadvantage of text box: the cursor changes to the "editing i-beam" over text boxes, but not over labels. Don't know if there's a cure for that, but I find it disconcerting.

You can insert an image onto the form and have an "OnClick" event for it. A couple of things to note: The Enabled and Locked properties both need to be set to Yes. Also, on the little experiment I ran, I found that clicking it made the "handles" appear, so it appeared that the image could be edited. To avoid this I added a DoCmd.GoToControl to send the focus to another control on the form as the forst line in the OnClick event.

Your issue of not triggering the OnCurrent event when the image is clicked may be the same as I've encountered with Label-type command buttons. You might put a transparent text box over the top of the image to get the focus on that record - but I don't know if Access would assume the click was for the text box or the image. I guess you could associate the OnClick event with the text box so the image just sits there looking pretty while the text box does the work.

Let us know how you make out.

HTH,
Jim
 
Thanks, that gave me the idea that finally worked. When I put the image on top of a transparent command button, Access defaulted to "seeing" the image first when the user clicks on it (and, thus, not executing the OnCurrent code). The problem was solved by sending the image to the back and bringing the transparent command button to the front.
 

Users who are viewing this thread

Back
Top Bottom