Others

How to Combine Stacked Query Results into One Row in Microsoft Access

Rana GarciaRana Garcia Oct 23, 2026 871 views

Question details

The user needs to combine related values returned in separate rows by a Microsoft Access query into a single line, mimicking a string concatenation or conditional combination approach found in Excel.

How to Combine Stacked Query Results into One Row in Microsoft Access
Product
Microsoft Access
Device & OS
not provided
Scenario
Organizing query results to display multiple related values as a comma-separated list or concatenated string on a single line instead of multiple rows.
Observed behavior
By default, Access query results natively display related sub-record values across multiple separate rows and lack a built-in text-joining function.
Before you start

Ensure you have a basic understanding of Visual Basic for Applications (VBA) in Microsoft Access, as concatenating rows requires creating and using a custom module.

Solution 1Recommended

Use a VBA Helper Function to Concatenate Sub-record Values

Since Access lacks a built-in function to concatenate rows like Excel's TEXTJOIN, you must create a custom VBA function to loop through related records and combine them into a single string.

Microsoft Access does not have a native aggregate function for combining multiple related rows into a single string within a query. To achieve this, you can utilize a custom VBA module, often referred to as a 'ConcatRelated' function.

This function queries the related table, loops through the records matching your criteria, and builds a single concatenated string that can be displayed directly in your query output.

1
Open the VBA Editor

Open your Microsoft Access database and press ALT + F11 on your keyboard to launch the VBA Editor window.

2
Create a New Module

In the top menu, click on 'Insert' and select 'Module' to create a new, blank VBA module.

3
Insert the Concatenation Code

Paste a standard concatenation script (such as the popular 'ConcatRelated' function found on The Access Web) into the module.

4
Save the Module

Save the newly created module (e.g., as 'Module_Concatenate') and close the VBA Editor to return to your Access database.

5
Call the Function in Your Query

Open your query in Design View. In an empty column, create an expression using your new function, passing your specific field names, table name, and criteria as arguments (e.g., Expr1: ConcatRelated("FieldName", "TableName", "ID = " & [ID])).

Use a VBA Helper Function to Concatenate Sub-record Values
Customizing the Arguments: Make sure to accurately update the table names, field names, and WHERE criteria in the query expression to match your specific database schema.
Free Microsoft Office alternative

Simplify Data Management with WPS Office

While Microsoft Access is a specialized database tool, many complex data concatenation and reporting tasks can be managed much easier using spreadsheets. WPS Office provides a free, lightweight, and user-friendly alternative to Microsoft Office. With a familiar UI and seamless migration, you can utilize advanced spreadsheet functions to combine data effortlessly without ever writing VBA code.

  1. 1. Download WPS Office: Visit the official WPS website to download and install WPS Office Free on your device.
  2. 2. Import Your Data: Export your Access data as an Excel or CSV file and open it seamlessly in WPS Spreadsheet.
  3. 3. Combine Rows Easily: Use built-in functions like TEXTJOIN to combine stacked values into a single row instantly.
100% format compatibility with Microsoft Excel (.xlsx, .xls, .csv)Built-in advanced formulas like TEXTJOIN for instant data concatenation without codingLightweight suite that installs quickly and runs smoothly on all devicesFamiliar user interface ensuring a zero-learning-curve transition
microsoft office alternative - wps office

Frequently Asked Questions

Can I combine rows in an Access query without using VBA?

No, Microsoft Access does not offer a built-in aggregate function (like Excel's TEXTJOIN) to concatenate strings across multiple rows within a standard query. A custom VBA module is currently the only robust method for this operation.

What is the equivalent of Excel's COUNTIF in Access?

In Access, you typically use the DCount domain aggregate function to count occurrences in a specific field that meet a certain criteria, functioning very similarly to COUNTIF in Excel.

Why is my VBA concatenation function returning errors in the query?

Errors usually occur if the field names, table names, or criteria strings passed to the VBA function are misspelled, or if there are missing quotation marks and ampersands when passing string arguments in the query expression.