Create event on image component

If we create a new database and not from your sample database, everything works fine. It is your sample that doesn't work.
@Mike Krailo
I don't know how @CJ_London and @theDBguy have done it, but your sample database doesn't work. When you add an unbound image to a continuous form, the image is just an object and is not a part of the record source. It means that if the first record is active and you click the forth or fifth or any other image, still the first record is active. So any image you click, the message box shows the id of the active record, not the ID of the row it's been clicked. (if the second record is active and you click fifth image, your message box says id=2)

From the images I see, it seems that @CJ_London has first clicked the record selector to activate a record, then has clicked the image to receive the correct ID.

The only way I was able to do what the OP needs, was to put a transparent textbox over the image and use the textbox's onclick event.

@theDBguy would you please upload your sample or at least explain how you did it?

thanks.
 
Last edited:
I don't know how @CJ_London and @theDBguy have done it, but your sample database doesn't work. When you add an unbound image to a continuous form, the image is just an object and is not a part of the record source. It means that if the first record is active and you click the forth or fifth or any other image, still the first record is active. So any image you click, the message box shows the id of the active record, not the ID of the row it's been clicked. (if the second record is active and you click fifth image, your message box says id=2)
This is a true statement since an image control cannot take focus. This is the same for any other control you put there that does not take focus such as a label. Since it does not take focus it does not move the selected record.
Use some other control that takes and image, but can also take focus. Most of these you are limited by the type of image. Or as you said, overlay it.
 
From the images I see, it seems that @CJ_London have first clicked the record selector to activate a record, then have clicked the image to recieve the correct ID.
No, I just clicked on the relevant control. I highlighted the record selector to show the message boxes related to the same record and showed the same id value

I still believe the OPs form is corrupted since they have not shown the result they are getting - not difficult to take a screenshot.

if they can’t be bothered to do this, or create a new form since everyone else has a problem with the OP’s form but not with one they create themselves then I don’t believe there is anything else to suggest
 
When you add an unbound image to a continuous form, the image is just an object and is not a part of the record source.
take a look at the example provided by the OP - the image control is bound
1701299177843.png


I've attached the example I created. the form Task is the OP's original unchanged - with that I get an error as reported in post #12. The form Task1 is the one I created and works based on the OP's requirement.

If you want to see the actual bound images, download from post #8 and modify the image value in the table for wherever you want to put it.
 

Attachments

if they can’t be bothered to do this, or create a new form .....
I don't think it makes any difference. No matter how many times he create new forms, I don't think you will be able to open it. Most of experts have experienced it when they've tried databases in Arabic or other languages. I've seen that @MajP had experienced it several times.
It's mostly because we use double-byte character sets. That's why correcting the controls name worked for me, but not for you.

But after all, I understand your frustration on this. OP seems not to be eager to have a working method (or is too busy to concentrate on this)

Edit : it seems we posted at the same time :)
 
take a look at the example provided by the OP - the image control is bound
View attachment 111212

I've attached the example I created. the form Task is the OP's original unchanged - with that I get an error as reported in post #12. The form Task1 is the one I created and works based on the OP's requirement.

If you want to see the actual bound images, download from post #8 and modify the image value in the table for wherever you want to put it.
@CJ_London with all respects, But it seems it's the same. If you don't activate a record first, your click image is showing the same id no matter on which image you click. I think it's what the OP says doesn't work.

Seems that using a transparent textbox is the only way.
 
@KitaYama - Many thanks. I now understand the OP's issue - and agree an unbound transparent textbox over the image control solves the problem
 
@theDBguy would you please upload your sample or at least explain how you did it?
In my case, the image control is bound to the image path field.

Here's my form in Design View.

1701317611980.png


However, I didn't test it far enough to click on the other records to remember that an Image Control can't take the focus. In this situation, my preference is to use a Transparent Button (in place of a Textbox). Cheers!
 
@Mike Krailo
I don't know how @CJ_London and @theDBguy have done it, but your sample database doesn't work. When you add an unbound image to a continuous form, the image is just an object and is not a part of the record source. It means that if the first record is active and you click the forth or fifth or any other image, still the first record is active. So any image you click, the message box shows the id of the active record, not the ID of the row it's been clicked. (if the second record is active and you click fifth image, your message box says id=2)
Ha ha, I didn't test that part of it because I ran out of time and was happy that I wasn't getting the original error anymore (as noted in post #12). In any case, it's so much easier to click on a button rather than an image for such things. Not sure what the overall driving goal of the OP's project is because so little information was given.
 
on a button rather than an image for such things
The problem with a button is you are limited to .bmp and does not have the features to Zoom, Stretch, Crop. So you are stuck with creating correct size BMP images.
 
The other solution I think would work (untested) is use a bound image or attachment with the data held in its own table. Then do a cartesian join to the data table. Now that image belongs to the record.
 
There is also the transparent property of a command button. Add a button over the image and set transparent to Yes.
 

Attachments

I still don't understand the need to click the image. I would have simply put a regular button next to the image or where ever to do what you need it to do. I see that there are ways to force this to work, just don't get why it's needed.
 
Thanks, it works when i create transparency button with click event and image above it
 

Users who are viewing this thread

Back
Top Bottom