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-03-07T22:05:38+00:00

    In your last post, you said I didn't assign a value to the strFiles. I don't see what names could be assigned other than the two paths. I hope your book will clarify this.

    The problem is you assigned values to strFiles1 and strFiles2, but not strFiles. Each is a SEPARATE variable. I think that may be what you are missing. When you define a variable it has a null value. You have to assign a value to use it. In your code you assign values to strFiles1 and strFiles2, but then you don't use those variables. You use strFiles.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2023-03-07T20:30:07+00:00

    In your last post, you said I didn't assign a value to the strFiles. I don't see what names could be assigned other than the two paths. I hope your book will clarify this.

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2023-03-07T20:24:02+00:00

    Thank you Scott. I have ordered your book and will study it when it arrives. However, I'm a little worried that with my limited knowledge and experience with Access that I might have trouble applying it to my needs. I'll give it a try.

    Walt

    Was this answer helpful?

    0 comments No comments
  4. ScottGem 68,840 Reputation points Volunteer Moderator
    2023-03-02T19:37:19+00:00

    I see the problem you are having, but I'm not getting through to you.

    I would suggest you get a copy of my book https://www.amazon.com/Microsoft-Office-Access-2007-VBA/dp/0789737310/ref=cm\_cr\_arp\_d\_product\_top?ie=UTF8

    Don't worry about the 2007, VBA hasn't changed appreciably since 2007. What you really need to understand is how variable work. I'll give you a brief summary.

    A variable is a name you apply to a value being used within your code. Variables are usually defined using a Dim statement. Once a variable is defined, it can then be assigned a value. However, if a variable is created and no value is assigned, the variable contains a Null value.

    Access is an object oriented p0latfomr. Everything is an object that has properties, one of which is the Name property. So, Controls on a form need to have names that you can reference as well as variables need to have names.

    So in your code you DIM only strFile, but you never assigned a value to strFile. So when you try to open strFile vial FollowHyperlink there is nothing to open.

    I'm also unsure why you are choosing the DblClick event instead of just the Click event. One usually usualy Click for a command button.

    You refer to controls on your form via Me.DigitFileName1 and Me.DigitFileName2. Do you have 2 controls on your form with those names?

    Was this answer helpful?

    0 comments No comments
  5. Anonymous
    2023-03-02T19:19:42+00:00

    Scott,

    I should have also mentioned that when I returned to the Code View page, the first line of the code, "Private Sub OpenImageBtn_DblClick(Cancel As Integer)" was highlighted in Yellow. Aslo, that part of the expression ".DigitFileName1" in the strFile1 line was highlighted in Blue.

    Was this answer helpful?

    0 comments No comments