Open Photographs in an Access Form

Anonymous
2023-01-26T23:26:10+00:00

I have a datatbase of photograph file names. In the DB I have a List Form that has a "Digital File Name" field. Question: Is it possable to create a command button on my List Form that will open the photo (that is stored in my Photos File on my C: drive) based on the digital file name for the selected record?

I am using Access 2016

Thanks Walt

Microsoft 365 and Office | Access | For home | Other

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

49 answers

Sort by: Newest
  1. ScottGem 68,840 Reputation points Volunteer Moderator
    2023-02-26T21:58:10+00:00

    strFile1 = "D:\Documents\Family Tree Maker\Wright-Jagoe(1) Media" & Me.DigitFileName1

    strFile1 = "D:\Documents\Family Tree Maker\Wright-Jagoe(1) Media" & Me.DigitFileName2

    If DIR(strFile1) = "" OR DIR(strFile2) = "" Then

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2023-02-26T18:16:32+00:00

    I have photos and images in two different folders. Is it possible to add code so that the search will include both folders?

    thanks Walt

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2023-01-29T22:54:00+00:00

    Scott, thanks, I will add this code, and for all your help. Walt

    Was this answer helpful?

    0 comments No comments
  4. ScottGem 68,840 Reputation points Volunteer Moderator
    2023-01-29T22:09:12+00:00

    My instructions were to use either

    Application.FollowHyperlink Me.txtFilename

    or

    Application.FollowHyperlink "C:\photos" & Me.txtFilename

    Apparently your field DigitalFilename contains just the filename and not the path. So you used the right method, but the wrong controlname. Once that was corrected it worked.

    What you might want to do is error trap this. Something like:

    Private Sub OpenImageBtn_DblClick(Cancel As Integer)

    Dim strFile as String

    strFile = "D:\Documents\Family Tree Maker\Wright-Jagoe(1) Media" & Me.DigitFileName

    If DIR(strFile) = "" Then

    MsgBox "File does not exist!"

    Else

    Application.FollowHyperlink strFile

    End If

    End Sub

    This way if you have a file name that doesn't have a corresponding file in the foilder, you will get an explanatory message.

    Was this answer helpful?

    0 comments No comments
  5. George Hepworth 23,120 Reputation points Volunteer Moderator
    2023-01-29T18:56:00+00:00

    Congratulations on solving the problem. Continued success with the project.

    Was this answer helpful?

    0 comments No comments