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. 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
  2. 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
  3. 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
  4. 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
  5. Anonymous
    2023-02-27T18:16:24+00:00

    You might like to take a look at Images.zip in my public databases folder at:

    https://onedrive.live.com/?cid=44CC60D7FEA42912&id=44CC60D7FEA42912!169

    If you have trouble downloading a specific file, clicking on the 'Download' button at the top of the page while no files are selected should download a zip file of all files in the folder, from which you should then be able to unpack the relevant file.

    In the zip archive the basic Images.accdb file allows images to be associated with each main record and stores each in a text column as the full path to the image in an Images table.  An Addresses_Images table models the many-to-many relationship type between the main Addresses table and the Images table.

    The main data entry form includes an unbound combo box of all image titles (which default to the file name if not amended by the user at the time of input).  This filters the form as follows:

    Private Sub cboFindImage_AfterUpdate()

        If Me.cboFindImage = "<All Images>" Then

            Me.FilterOn = False

        Else

            Me.Filter = "EXISTS (SELECT * FROM Addresses_Images INNER JOIN Images " & _

                "ON Addresses_Images.ImageID = Images.ImageID " & _

                "WHERE Addresses_Images.AddressID = Addresses.AddressID  AND ImageTitle = """ & Me.cboFindImage & """)"

            Me.FilterOn = True

        End If

    End Sub

    The combo box's RowSource property is the following UNION operation, which adds an <All Images> row at the start of the list:

    SELECT "<All Images>"AS ImageTitle, 0 AS SortColumn

    FROM Images

    UNION

    SELECT ImageTitle, 1

    FROM Images

    ORDER BY SortColumn, ImageTitle;

    The images for each address are displayed in small controls in a continuous subform, which also includes a command button in its detail section to open the currently selected image in its associated application with:

    Private Sub cmdOpenImage_Click()

        Application.FollowHyperlink Me.ImagePath

    End Sub

    Was this answer helpful?

    0 comments No comments