Create Microsoft Access Forms to Filter Photos by Related Tables
Question details
Create an Access form that filters and displays photographs by related subject, group, and section categories.
- Product
- Microsoft Access
- Device & OS
- not provided
- Scenario
- A Paradox database with hierarchical categories and approximately 10,000 photographs is being migrated to Access.
- Observed behavior
- The desired form lets users select categories and view the matching photo records.
Check how subjects, groups, and sections relate to each other, and identify the key fields and photo locations in the migrated data. Confirm that the category tables and photo records are available in Access before building the form.
Build a photo search form with category combo boxes and a subform
Use this approach to select one or more categories and display matching photo records on the same screen.
The photo form does not need to use all four tables directly. The Photos table can hold category foreign keys, while combo boxes display readable category names.
If the categories form a strict hierarchy, consider whether storing only the lowest-level key is sufficient. If you store all three keys, make sure the selected values remain consistent with the hierarchy.
In Access, open Database Tools > Relationships. Add the Photos, Subjects, Groups, and Sections tables, then link their primary and foreign keys. Enable referential integrity where the existing data supports it.
Select Create > Form Design and save a blank form as frmPhotoSearch. Add three unbound combo boxes named cboSubject, cboGroup, and cboSection. Set each Row Source to its category table, with the ID in the first column and the name in the second; hide the ID column if desired.
Select Create > Query Design, switch to SQL View, and create a query using your actual table and field names. For example: SELECT * FROM Photos WHERE ([SubjectID]=Forms![frmPhotoSearch]![cboSubject] OR Forms![frmPhotoSearch]![cboSubject] Is Null) AND ([GroupID]=Forms![frmPhotoSearch]![cboGroup] OR Forms![frmPhotoSearch]![cboGroup] Is Null) AND ([SectionID]=Forms![frmPhotoSearch]![cboSection] OR Forms![frmPhotoSearch]![cboSection] Is Null); Save it as qryFilteredPhotos.
Open frmPhotoSearch in Design View and use the Subform/Subreport control to add a subform based on qryFilteredPhotos. Include the fields users need to identify each photo. If photos are stored in an Access Attachment field, include an attachment control in the subform to display them.
Add a button to frmPhotoSearch. In its On Click property, create an embedded macro with the Requery action and set Control Name to the subform control's name. Save the form, choose categories, and click the button to refresh the results.
Open frmPhotoSearch in Form View and try individual and combined selections. Clear a combo box to leave that category unfiltered, then click the search button again. Check that the returned records and photographs match the selections.

Prepare Photo Category Lists with WPS Office
WPS Office is a free, lightweight alternative with a familiar interface for working on spreadsheets and documents. Use it to review or prepare category lists for migration; it does not replace Microsoft Access forms or fix Access database issues.

Frequently Asked Questions
Does the photo form need all four tables in its record source?
No. A query based on the Photos table can supply the photo records, while combo boxes use the category tables to display subject, group, and section names.
How do I show all photos when a category is not selected?
Use an optional query condition such as [SubjectID]=Forms![frmPhotoSearch]![cboSubject] OR Forms![frmPhotoSearch]![cboSubject] Is Null. Clear the combo box and requery the subform to remove that filter.
Can the group and section choices depend on the selected subject?
Yes. Set each dependent combo box's Row Source to a query filtered by the parent selection, then use the parent combo box's After Update event to clear and requery the dependent control. Your tables need fields that define the parent-child relationships.
How can I display a photograph instead of its file path?
If the photo is stored in an Access Attachment field, add an attachment control to the form. If the field stores a file path, configure an image control to load the file and ensure that the path is accessible.




