Solved Hide image in Report based on Pixel Size (1 Viewer)

Saphirah

New member
Local time
Today, 06:32
Joined
Apr 5, 2020
Messages
28
Hey everyone,

for my current Access Project i need to create a report and show/hide an image based on the size of the image.
For this i used the Paint and Print Event of the Details section of the report. My code looks like this

Code:
Private Sub Detail_Paint()
    Screenshot.Visible = Screenshot.ImageWidth < 600 And Screenshot.ImageHeight < 600
    MsgBox ("Width: " & Screenshot.ImageWidth & ", Height: " & Screenshot.ImageHeight)
End Sub

Screenshot is an image control with the control source set to a string value, that stores the file path of the image.
Now my problem is, whenever i try to execute the code, the message box returns 0 for both Width and height.

So my assumtion was that the image is probably not loaded yet. You can see the final image on the report though, so it is not a problem with the image file.

Does anyone know a different approach, that allows me to use ImageWidth and ImageHeight, or maybe determine the size of the image in a different way?
Thank you very much!
 

Saphirah

New member
Local time
Today, 06:32
Joined
Apr 5, 2020
Messages
28
Okay i found a solution. I added the following line:

Code:
Private Sub Detail_Paint()
    Screenshot.Picture = Me.ScreenshotLink
    Screenshot.Visible = Screenshot.ImageWidth < 6000 And Screenshot.ImageHeight < 6000
    MsgBox ("Width: " & Screenshot.ImageWidth & ", Height: " & Screenshot.ImageHeight)
End Sub

ScreenshotLink is my string value for the image, as mentioned above.
After this the code works
 

Users who are viewing this thread

Top Bottom