logo
search
Others

How to Open a Photograph from an Access Form Using a File Name

Emma BrownEmma Brown Oct 15, 2026 869 views

Question details

The user needs to open an external image file directly from a Microsoft Access form using the file name or file path stored in a database field.

How to Open a Photograph from an Access Form Using a File Name
Product
Microsoft Access
Device & OS
not provided
Scenario
A user is interacting with an Access database form that stores photo file names. They want to click or double-click a control on the form to launch the image in the default Windows photo viewer.
Observed behavior
The file name or path is stored in a bound field, and a VBA script is required to construct the full file path and execute the command to open the photograph.
Before you start

Verify that your stored file paths are accurate and that the image files physically exist in the designated directory on your local drive or network before attempting to open them.

Solution 1Recommended

Use Application.FollowHyperlink to Open the Image

Use a simple VBA command on a form control's event to launch the default photo viewer using the stored file name.

The Application.FollowHyperlink method in VBA acts like clicking a standard hyperlink. It instructs Windows to open the specified file path using the default application associated with that file type.

1
Open Form in Design View

Right-click your Access form in the Navigation Pane and select 'Design View'. Click on the control (e.g., a text box or button) you want to use to trigger the action.

2
Access the VBA Editor

Open the Property Sheet, navigate to the 'Event' tab, and click the builder button (...) next to 'On Double Click' or 'On Click'. Select 'Code Builder' to open the VBA editor.

3
Enter the Code for Full Paths

If your field contains the entire file path (e.g., C:\Photos\image1.jpg), enter the following code: Application.FollowHyperlink Me.txtFilename (replace 'txtFilename' with the actual name of your bound control).

4
Enter the Code for File Names Only

If your field only stores the file name (e.g., image1.jpg), concatenate the folder path by entering: Application.FollowHyperlink "C:\Photos\" & Me.txtFilename

Use Application.FollowHyperlink to Open the Image
Path Verification: Ensure that your folder path string ends with a backslash (\) before concatenating it with the file name to form a valid Windows path.
Free Microsoft Office alternative

Looking for a Lightweight Alternative to Microsoft Office?

While WPS Office does not feature a direct database equivalent to Access, it serves as a powerful, free alternative for Microsoft Word, Excel, and PowerPoint. Enjoy a highly compatible office suite without heavy subscription fees.

Fully compatible with Microsoft Office formats, including .docx, .xlsx, and .pptx.Lightweight installation with fast loading speeds across all devices.Familiar user interface for seamless and intuitive migration.Comprehensive built-in PDF toolkit for editing, converting, and signing documents.
QA img-9

Frequently Asked Questions

Why does Access show a security warning when using Application.FollowHyperlink?

Microsoft Access often prompts a security notice when opening external files or hyperlinks to protect against malicious scripts. You can prevent this warning by adding the folder containing your photographs to the 'Trusted Locations' list in the Access Trust Center settings.

Can I open other file types, like PDF or Word documents, using this method?

Yes. The Application.FollowHyperlink method uses the Windows shell to open the file. It will successfully open any file type (like PDFs, Word documents, or Excel spreadsheets) in the default application assigned to that extension in your Windows settings.

What happens if the file names in my database contain spaces?

The VBA method handles spaces in file paths natively. As long as the concatenated string correctly matches the actual path on your drive (e.g., "C:\My Photos\Vacation 2023.jpg"), Windows will recognize the spaces and open the file without issues.