I recently was creating a continuous form (using Access 2007) and wanted to use an Image control as a delete button, of sorts. I rapidly encountered a small problem (what I personally perceive to be a glitch/bug within Access). Access would not always delete the record on which I was clicking the Delete Image control. So in fact, it was deleting the wrong records! So I started performing a few tests and discovered that the Image Control was not returning the proper primary key (PK) value for the record on which the Image Control was clicked?! The only way it deleted the proper record was to first set the focus on one of the other controls for the record I wish to delete and then click on the delete image. So you need to manually change the focus. This obviously was not a potential production solution for real-world usage.
I asked my fellow MVPs to see if (i) if it the behavior was reproducible, (ii) if this was a known issue and receive the following informative and confirming explanation from Dirk Goldgar:
I can confirm that, at least for Access 2010, clicking on an image control doesn’t move the focus to the control, and thus doesn’t change the current record. It seems that, like a label, the image control can’t receive the focus, so clicking on it has no effect on what control and record are active and current.
This would explain the issue.
The Workaround/Solution
The only solution I came up with (and later was offered the same solution by other MVPs) was to overlay a transparent button (Format -> Transparent = Yes) over top of the Image Control and use it’s On Click event instead. So use the image for the visual you are after, but use the button for the actual action.
just spent 6 hours messing around with this problem…. and this was the solution. Had the same issue with a img box, not giving me the correct records for on click events.
I’m glad you found the site and workaround.
Hard to believe that after all these years the issue still remains.
Thanks. It very useful.