How to Open an Image with a Double-Click Event in Access
Question details
The user wants to dynamically open a specific image clicked in a continuous Microsoft Access form without hard-coding the path to a specific Photo Viewer DLL.

- Product
- Microsoft Access
- Device & OS
- Windows
- Scenario
- A continuous Access form displays multiple photo records. The goal is to open the full-size version of whichever specific image the user double-clicks.
- Observed behavior
- The current approach relies on a fixed DLL path for Windows Photo Viewer, which fails or lacks flexibility. The goal is to pass the correct image path to the system's default image viewer instead.
Ensure that the file paths stored in your Access database correctly point to the accessible image files on your local drive or network, and verify that Windows has a default image viewer assigned.
Use Application.FollowHyperlink in VBA
Replace hard-coded DLL calls with the Application.FollowHyperlink method to securely open the clicked image in the user's default Windows image application.
Using Application.FollowHyperlink is the standard best practice for opening external files from Microsoft Access. It delegates the task to the Windows operating system, which automatically uses the default application assigned to that specific file type (e.g., JPG, PNG).
This approach completely eliminates errors caused by missing, moved, or outdated DLL files associated with older Windows Photo Viewer versions.
Right-click your continuous form in the navigation pane and select 'Design View'.
Select the image control or the text box that contains the file path for the image. Open the Property Sheet (F4).
In the Property Sheet, click on the 'Event' tab and locate the 'On Dbl Click' property.
Click the ellipsis (...) button next to the 'On Dbl Click' field and choose 'Code Builder' to open the VBA editor.
Enter the following code inside the event sub: Application.FollowHyperlink Me.YourImagePathControlName (ensure you replace 'YourImagePathControlName' with the actual name of the control holding your file path).
Save the VBA module, switch back to Microsoft Access, change the form to 'Form View', and double-click an image to verify it opens in the default Windows image viewer.

Simplify Your Work with WPS Office
While Microsoft Access handles complex relational databases, many everyday data management, filtering, and reporting tasks can be easily managed using spreadsheets without writing VBA code. WPS Office provides a lightweight, highly compatible, and free alternative to Microsoft Office, ensuring seamless handling of your daily document and data needs.
- 1. Download the Installer: Visit the official WPS Office website and download the free installation package.
- 2. Install WPS Office: Run the downloaded file and follow the on-screen instructions to install the suite on your computer.
- 3. Start Managing Data: Open WPS Spreadsheet to easily manage, sort, and analyze your data sets without the need for complex database programming.

Frequently Asked Questions
Why doesn't my image open when I double-click the Access form?
This usually happens if the file path stored in your database is incorrect, missing, or if the VBA code references the wrong control name. Ensure your code points exactly to the text box or field containing the valid file path.
How do I change the default image viewer that opens my files?
In Windows, go to Settings > Apps > Default apps. Look for 'Photo viewer' or search by file type (like .jpg) and select your preferred application. Access will automatically use this setting when running Application.FollowHyperlink.
Can I open images stored as OLE objects using Application.FollowHyperlink?
No, Application.FollowHyperlink only works for external file paths stored as text (e.g., 'C:\Photos\image.jpg'). If your images are embedded directly into the database as OLE attachments, you will need to extract them first or use the default attachment controls to view them.
How can I improve my Access form's loading speed with many images?
Instead of loading high-resolution images directly into the continuous form, generate and display small thumbnails. Store the path to the high-resolution image in a hidden text box and call that hidden field during the double-click event.




