Set an Access Subreport Record Source by Table Name
Question details
Display the first few records from an Access table named in the main report.

- 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.
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.
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.
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.
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.
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.
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.
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.

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.

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.




