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: Most helpful
  1. ScottGem 68,840 Reputation points Volunteer Moderator
    2023-02-28T21:38:17+00:00

    Scott, I am really confused being less than a beginner with code. I'm not sure which "three lines" are the ones you suggested.

    Could you please show me how the code should look?

    OK, this was the original code I suggested:

    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

    You then said that you had photos in 2 folders and asked how to deal with it. So I posted just the lines that needed to be changed.

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

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

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

    You have to use the whole code not just the modified lines.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2023-02-28T21:13:42+00:00

    Scott, I am really confused being less than a beginner with code. I'm not sure which "three lines" are the ones you suggested.

    Could you please show me how the code should look?

    Was this answer helpful?

    0 comments No comments
  3. ScottGem 68,840 Reputation points Volunteer Moderator
    2023-02-27T20:12:57+00:00

    You still have to use the rest of the code in the IF statement.

    The three lines I suggested were to replace the just the three lines in the rest of your code.

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2023-02-27T19:33:22+00:00

    I use this and there is still something wrong. Help!

    Private Sub OpenImageBtn_DblClick(Cancel As Integer)

    StrFile1 = "D:\Documents\Family Tree Maker\Wright-Jagoe Media\" & Me.DigitalFileName1 
    
    strFile2 = "D:\Documents\Family Tree Maker\Laidlaw-Fowler Media\" & Me.DigitalFileName2 
    
    If Dir(StrFile1) = "" Or Dir(strFile2) = "" Then 
    

    End Sub

    Walt

    Was this answer helpful?

    0 comments No comments
  5. Anonymous
    2023-02-27T19:20:22+00:00

    I think I got it. Take out line 2 from both strFile1 and strFile2.

    Was this answer helpful?

    0 comments No comments