Zoom Picture object in Access

siamandm
BronzeLounger
Posts: 1268
Joined: 01 May 2016, 09:58

Zoom Picture object in Access

Post by siamandm »

Hello All,

I have a form (ProductF) which contains Image object called PictureImage, with an on click event to open a form ZoomPictureF

and the form ZoomPicture form is contains only one Image object called ZoomedPicture
in the Form_Open event i have this code

Me.ZoomedPicture.Picture = Forms!ProductF!ZoomedPicture.Picture


now when i click on the image on the ProductF , the ZoomPicture is opening but it is not showing the image form the productF

my question is :
1- is in open event is the right place or i have to put this code in the on load and why?
2- why it is not showing the picture inside the zoomPicture form?


Regards
User avatar
HansV
Administrator
Posts: 78631
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Zoom Picture object in Access

Post by HansV »

Could you attach a zipped copy of the database? You can remove stuff that isn't relevant to the problem from the copy.
Best wishes,
Hans
siamandm
BronzeLounger
Posts: 1268
Joined: 01 May 2016, 09:58

Re: Zoom Picture object in Access

Post by siamandm »

here it is,
i have changed the way i did to :

Code: Select all

Private Sub YourPictureBox_Click()
    DoCmd.OpenForm "frmZoom", , , , , acDialog
    Forms!frmZoom.YourZoomedPictureBox.Picture = Me.YourPictureBox.Picture
End Sub
I would like to add code handler to this code, when i close the frmZoom it shows an error.
the form name is productF
DataBase.zip
You do not have the required permissions to view the files attached to this post.
Last edited by siamandm on 08 May 2024, 05:39, edited 1 time in total.
User avatar
HansV
Administrator
Posts: 78631
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Zoom Picture object in Access

Post by HansV »

Thanks!
The error message occurs because you open the zoom form with acDialog, so the line

Me.ZoomedPicture.Picture = Forms!ProductF!ZoomedPicture.Picture

is only executed AFTER the zoom form has been closed by the user.
Solution:
1) Delete the above line
2) Set the Control Source of ZoomImageObject on the zoom form to

=[CurrentProject].[Path] & "\Images\" & [Forms]![ProductF]![ProductPicture]

Remark: I'd set the Record Selectors and Navigation Buttons properties of the zoom form to No, and the Scroll Bars property to Neither.
See the attached version.

DataBase.zip
You do not have the required permissions to view the files attached to this post.
Best wishes,
Hans
siamandm
BronzeLounger
Posts: 1268
Joined: 01 May 2016, 09:58

Re: Zoom Picture object in Access

Post by siamandm »

Thank you very much dear it worked perfect
User avatar
Gasman
2StarLounger
Posts: 119
Joined: 22 Feb 2022, 09:04

Re: Zoom Picture object in Access

Post by Gasman »

@HansV
I was keen to see the code, and downloaded the zip file.

I get the zip file as password protected and if I try and unzip anyway, files are created, but I get 'Can't read File header' for the image and 'Unrecogised database format' for the db, and I am on 2019 on this laptop.?
Using Access 2007/2019.
Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime.
Please, please use code tags when posting code snippets, click the </>icon.
Debug.Print is your lifesaver.
siamandm
BronzeLounger
Posts: 1268
Joined: 01 May 2016, 09:58

Re: Zoom Picture object in Access

Post by siamandm »

the password is : eileens
User avatar
HansV
Administrator
Posts: 78631
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Zoom Picture object in Access

Post by HansV »

That's weird - it's possible that the database cannot be opened, since I am on Microsoft 365. But the image should be accessible - I downloaded and extracted the zip file just now to test. The picture opened without error.

Anyway, the ProductF form has text box named ProductPicture and an image control with Control Source

=[CurrentProject].[Path] & "\Images\" & [ProductPicture]

The On Click event procedure of the image control is

Code: Select all

Private Sub ProductPictureImage_Click()
    DoCmd.OpenForm "ZoomPictureF", , , , , acDialog
End Sub
The ZoomPictureF form has a larger image control, with Control Source

=[CurrentProject].[Path] & "\Images\" & [Forms]![ProductF]![ProductPicture]

The SizeMode property of both image controls has been set to Zoom.
Best wishes,
Hans
User avatar
Gasman
2StarLounger
Posts: 119
Joined: 22 Feb 2022, 09:04

Re: Zoom Picture object in Access

Post by Gasman »

Thank you.
It was the password that was at fault.
Once that was entered, the DB opened, I was able to see the image, both in the DB and from file explorer.
Using Access 2007/2019.
Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime.
Please, please use code tags when posting code snippets, click the </>icon.
Debug.Print is your lifesaver.
User avatar
HansV
Administrator
Posts: 78631
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Zoom Picture object in Access

Post by HansV »

:thumbup:
Best wishes,
Hans