Consulting

Results 1 to 6 of 6

Thread: Zoom on attachment

  1. #1
    VBAX Newbie
    Joined
    May 2021
    Posts
    4
    Location

    Zoom on attachment

    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
    Last edited by tact; 05-13-2021 at 02:54 AM.

  2. #2
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,296
    Location
    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.

  3. #3
    VBAX Newbie
    Joined
    May 2021
    Posts
    4
    Location
    Thank you for responding. I am getting compile errors but working through them. I will let you know how it goes.

    Quote Originally Posted by OBP View Post
    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.

  4. #4
    VBAX Newbie
    Joined
    May 2021
    Posts
    4
    Location
    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

  5. #5
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,296
    Location
    Well done working it out.

    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.

  6. #6
    VBAX Newbie
    Joined
    May 2021
    Posts
    4
    Location
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •