Office Settings & Configuration

How to Display Random Images from File Paths in an Access Form

Anum MushtaqAnum Mushtaq Nov 3, 2026 871 views

Question details

The user needs to display five randomly selected images in an unbound Microsoft Access form by loading them from file paths stored in a Short Text field, avoiding the use of Attachment fields.

How to Display Random Images from File Paths in an Access Form
Product
Microsoft Access
Device & OS
not provided
Scenario
Designing an unbound Access form to dynamically load and display multiple associated images based on random selection or a specific record association.
Observed behavior
The user aims to successfully load images into separate image controls from stored file paths while ensuring the form handles the Load event properly without folder permission or missing file errors.
Before you start

Ensure that all your image files are stored in a dedicated, accessible local folder or network drive, and verify that the file paths are correctly recorded in your database table.

Solution 1Recommended

Use a Subform with Bound Image Controls

The simplest, code-free method is to use a continuous subform where the Image control's Control Source is directly bound to the text field containing the image file path.

By binding image controls to text paths, Access will dynamically render the images without taking up valuable database storage space.

1
Create an Image Path Table

Create a database table with a Short Text field designed to store the complete file paths (e.g., C:\Images\pic1.jpg) of your images.

2
Create a Subform

Generate a subform based on this table and insert an Image control into the Detail section of the form design.

3
Bind the Control Source

Open the Property Sheet for the Image control, locate the 'Control Source' property, and set it to the exact name of your text field.

4
Embed the Subform

Embed this subform into your main parent form. It will now automatically display the multiple images associated with the current record without requiring VBA.

Use a Subform with Bound Image Controls
No VBA Code Required: This method automatically handles loading the images for each record, eliminating the need to write complex VBA code for the On Load event.
Free Microsoft Office alternative

Manage Your Data Seamlessly with WPS Spreadsheet

While Microsoft Access is a dedicated database tool, many complex data tracking and image cataloging tasks can actually be handled efficiently in a spreadsheet. WPS Office provides a lightweight, highly compatible alternative for Word, Excel, and PowerPoint tasks.

Fully compatible with Microsoft Excel (.xlsx), Word (.docx), and PowerPoint (.pptx) file formats.Easily insert, align, and manage images directly within your spreadsheet cells without complex VBA code.Free and lightweight, avoiding the heavy system resource usage of legacy database software.Familiar tabbed user interface makes transitioning from Microsoft Office completely seamless.
microsoft office alternative - wps office

Frequently Asked Questions

Why do I get an error during the Access form Load event when displaying images?

Load errors typically occur if the file path stored in your database points to a folder that Access lacks permissions to read, or if the referenced file has been moved or deleted. Adding error-handling routines in your VBA code prevents the form from crashing when a path is invalid.

Why should I store file paths instead of using an Attachment field in Access?

Storing file paths in a Short Text field keeps your overall database size minimal. Attachment fields store the actual files inside the database, which can quickly inflate your file size toward the strict 2GB limit in Access, causing severe performance issues and potential corruption.

How can I randomize the image selection in an Access query?

You can randomize records by adding a calculated field to your query using the Rnd() function, such as 'RandomSort: Rnd([ID])'. You can then sort your query results by this field and restrict the return to the Top 5 results to get random image paths.