PDA

View Full Version : [SOLVED:] Zoom on attachment



tact
05-13-2021, 01:04 AM
Hi.

I have a table and form that has 8 attachment fields to add photos. I would like to be able to see each photo enlarged when I click on them, but know little about coding event procedures in Access (Excel is more my thing).

Also, is it possible to double-click on the first attachment and have it open all 8 attachments in Microsoft Photo?

Thank you.

Anton

OBP
05-14-2021, 11:21 AM
I have never used Attachment fields but I do use code to open existing documents based on their Folder location.
This is the code that I use
On Error GoTo errorcatch

If Me.Document_Type = ".jpg" Or Me.Document_Type = ".jpeg" Or Me.Document_Type = ".gif" Then
Me.test.Class = "Package" ' Set class name.
Me.test.OLETypeAllowed = acOLEEmbedded
Me.test.SourceDoc = Me.Document_Location
Me.test.Action = acOLECreateEmbed
Me.test.SizeMode = acOLESizeZoom
With Me.test
.Action = acOLEActivate
.Verb = acOLEVerbOpen
End With
If Me.Document_Type = ".jpg" Or Me.Document_Type = ".jpeg" Then Me.Include_in_Photo_Catalogue.Visible = True
Exit Sub
End If
If Me.Document_Type = ".pdf" Then
MsgBox "1"
Me.Document_Link.Class = "Package" ' Set class name.
MsgBox "2"
Me.Document_Link.OLETypeAllowed = acOLELinked
MsgBox "3"
Me.Document_Link.SourceDoc = Me![Document Location]
MsgBox "4"
Me.Document_Link.Action = acOLECreateLink
MsgBox "5"
Me.Document_Link.SizeMode = acOLESizeZoom
With Me.Document_Link
.Action = acOLEActivate
.Verb = acOLEVerbOpen
End With
Else
Application.FollowHyperlink Me.Document_Location, , True
End If
Exit Sub

errorcatch:
MsgBox Err.Description
Exit Sub


It is an old Document Management database and may no longer work very well, but you are welcome to a copy.
I am not sure bout opening all of the attachments other than by looping through the fields.

tact
05-14-2021, 05:55 PM
Thank you for responding. I am getting compile errors but working through them. I will let you know how it goes.


I have never used Attachment fields but I do use code to open existing documents based on their Folder location.
This is the code that I use
On Error GoTo errorcatch

If Me.Document_Type = ".jpg" Or Me.Document_Type = ".jpeg" Or Me.Document_Type = ".gif" Then
Me.test.Class = "Package" ' Set class name.
Me.test.OLETypeAllowed = acOLEEmbedded
Me.test.SourceDoc = Me.Document_Location
Me.test.Action = acOLECreateEmbed
Me.test.SizeMode = acOLESizeZoom
With Me.test
.Action = acOLEActivate
.Verb = acOLEVerbOpen
End With
If Me.Document_Type = ".jpg" Or Me.Document_Type = ".jpeg" Then Me.Include_in_Photo_Catalogue.Visible = True
Exit Sub
End If
If Me.Document_Type = ".pdf" Then
MsgBox "1"
Me.Document_Link.Class = "Package" ' Set class name.
MsgBox "2"
Me.Document_Link.OLETypeAllowed = acOLELinked
MsgBox "3"
Me.Document_Link.SourceDoc = Me![Document Location]
MsgBox "4"
Me.Document_Link.Action = acOLECreateLink
MsgBox "5"
Me.Document_Link.SizeMode = acOLESizeZoom
With Me.Document_Link
.Action = acOLEActivate
.Verb = acOLEVerbOpen
End With
Else
Application.FollowHyperlink Me.Document_Location, , True
End If
Exit Sub

errorcatch:
MsgBox Err.Description
Exit Sub


It is an old Document Management database and may no longer work very well, but you are welcome to a copy.
I am not sure bout opening all of the attachments other than by looping through the fields.

tact
05-14-2021, 06:27 PM
Thank you for putting me on the right track.

It's not elegant, but this does what I want it to regarding picture size. I won't need to view these photos in an external program now.


Private Sub Photo_1_GotFocus()
Me.Photo_1.Width = 10000
Me.Photo_1.Height = 10000
End Sub


Private Sub Photo_1_LostFocus()
Me.Photo_1.Width = 1000
Me.Photo_1.Height = 1000
End Sub

OBP
05-15-2021, 12:52 AM
Well done working it out. :thumb

Sorry about the error, I should have supplied you with the VBA Editor Reference Settings to go with the code, it is a while since I supplied the database to someone else and I forgot it needed them.

tact
05-16-2021, 03:07 AM
Don't sweat it. You were able to point me in a logical direction and it got the job done.

Thanks again.

I added the same code for photos 2 - 8 so now all of my photos zoom on focus.

Cheers