Others

Set an Access Subreport Record Source by Table Name

Olivia MillerOlivia Miller Nov 27, 2026 868 views

Question details

Display the first few records from an Access table named in the main report.

Set an Access Subreport Record Source by Table Name
Product
Microsoft Access
Device & OS
not provided
Scenario
A main report lists table names, and each related subreport should show sample rows from the corresponding table.
Observed behavior
The desired result is a subreport that displays sample records for the table named in each main report record.
Before you start

Decide how many rows to show and which field determines their order in each table. Identify fields with compatible data types that can appear in the same subreport columns.

Solution 1Recommended

Link the Subreport to a UNION Query of Sample Rows

Use this approach when the tables can provide a common set of columns for one subreport layout.

In Access, a report uses a Record Source rather than a Row Source. A UNION query can combine sample rows from multiple tables and label each row with its source table name.

1
Prepare the main report source

Create or open a metadata table with one record per source table and a text field named TableName. In the main report's Property Sheet, set Record Source to this table or a query based on it.

2
Create a TOP query for each table

Select Create > Query Design > SQL View and enter a query such as SELECT TOP 5 'Customers' AS SourceTable, CustomerID AS RowID, CustomerName AS DisplayValue FROM Customers ORDER BY CustomerID;. Save it as qTopCustomers. Repeat for each table, using the same column aliases and compatible data types.

3
Combine the sample queries

Create another query in SQL View using SELECT SourceTable, RowID, DisplayValue FROM qTopCustomers UNION ALL SELECT SourceTable, RowID, DisplayValue FROM qTopOtherTable;. Add a SELECT for each saved TOP query and save the UNION query.

4
Set the subreport source

Open the subreport in Design View, select the report in the Property Sheet, and set Record Source to the saved UNION query. Add controls bound to RowID and DisplayValue.

5
Link and test the reports

In the main report's Design View, select the subreport control. In its Property Sheet, set Link Master Fields to TableName and Link Child Fields to SourceTable. Open the main report in Print Preview and check that each table name displays its own sample rows.

Link the Subreport to a UNION Query of Sample Rows
Ordering and table structure: Use an ORDER BY field that defines the intended first rows; a unique sort key avoids extra rows caused by ties in TOP queries. If tables have incompatible fields or need different layouts, define separate report designs or a VBA-based dynamic Record Source instead.
Free Microsoft Office alternative

Review Exported Access Data in WPS Spreadsheets

WPS Office is a free, lightweight Office alternative with a familiar interface and support for common Microsoft Office formats, making exported data easy to work with. It does not change Access subreport settings or replace an Access database.

Review and organize data exported from Access in spreadsheetsOpen and edit Microsoft Excel XLSX and XLS filesUse a familiar interface for everyday document and spreadsheet workMove existing Office-format files into WPS Office with minimal disruption
QA img-9

Frequently Asked Questions

Does an Access subreport use Row Source or Record Source?

A report uses Record Source. Open the subreport in Design View and find Record Source in the report's Property Sheet. Row Source is typically used for controls such as combo boxes and list boxes.

How does the subreport know which table's rows to display?

The UNION query labels each row with a SourceTable value. Set the subreport control's Link Master Fields to the main report's TableName field and Link Child Fields to SourceTable.

How can I change the number of sample rows?

Open each saved sample query in SQL View and change TOP 5 to the desired number. Keep an ORDER BY clause with a unique sort key so the selection is predictable.

What if my tables have different columns?

A UNION query requires the same number of corresponding columns with compatible data types. Map suitable fields to common aliases, or consider separate report layouts or a VBA-based dynamic Record Source if one layout cannot represent the tables.

Can I build the table-name list automatically?

Yes. You can use VBA and the DAO TableDefs collection to populate a metadata table with table names and field information. Use a query that returns one record per table as the main report's Record Source.