Split Comma-Separated Text into Columns in an Access 2016 Query
Question details
Split a field containing up to eight comma-separated phrases into Criteria1 through Criteria8 in an Access query.

- Product
- Microsoft Access 2016
- Device & OS
- not provided
- Scenario
- The user wants to extract individual phrases in Access without exporting the data to Excel.
- Observed behavior
- Each phrase should appear in its corresponding query column, with missing positions left blank.
Identify the table and field containing the comma-separated text, and make sure the database is trusted so Access can run VBA functions. The example assumes commas are separators, not part of the phrases themselves.
Use a VBA function to extract each criterion in an Access query
Use this approach to display up to eight phrases in separate query columns without changing the source table.
The function uses VBA Split to create an array and returns the requested item. It returns Null when the source is empty or the requested position is missing.
The Split syntax shown in documentation describes the function's arguments; it is not a complete function definition that can be pasted into a module.
In Access, open an existing standard module or choose Create > Module. Paste the following code below any existing declarations, and save the module under a name such as modCriteria: Public Function CriterionAt(ByVal sourceText As Variant, ByVal position As Long) As Variant Dim parts As Variant If IsNull(sourceText) Or position < 1 Then CriterionAt = Null Exit Function End If If Len(Trim(CStr(sourceText))) = 0 Then CriterionAt = Null Exit Function End If parts = Split(CStr(sourceText), ",") If position - 1 > UBound(parts) Then CriterionAt = Null Else CriterionAt = Trim(parts(position - 1)) End If End Function
Choose Create > Query Design, switch to SQL View, and enter the SQL below. Replace YourTable and CommaField with your actual table and field names: SELECT CriterionAt([CommaField], 1) AS Criteria1, CriterionAt([CommaField], 2) AS Criteria2, CriterionAt([CommaField], 3) AS Criteria3, CriterionAt([CommaField], 4) AS Criteria4, CriterionAt([CommaField], 5) AS Criteria5, CriterionAt([CommaField], 6) AS Criteria6, CriterionAt([CommaField], 7) AS Criteria7, CriterionAt([CommaField], 8) AS Criteria8 FROM [YourTable];
Click Run on the Query Design ribbon. Check that each phrase appears in the expected Criteria column and that positions beyond the number of phrases are blank.

Work with Office documents in WPS Office
WPS Office is a free, lightweight alternative with a familiar interface for working with documents, spreadsheets, and presentations. Its Office-format compatibility helps you move existing files into your workflow. It does not run or repair Microsoft Access queries.

Frequently Asked Questions
Why does pasting the Split syntax into my module cause an error?
The documented syntax is a reference to the function's arguments, not executable code by itself. Open a standard module through Create > Module and add a complete Public Function that calls Split, such as CriterionAt in the solution.
What happens if a record has fewer than eight phrases?
The function checks the array's upper bound and returns Null for a missing position. The corresponding Criteria column appears blank in the query results.
Why can't my query find the VBA function?
Check that CriterionAt is declared Public in a standard module, that the module has a different name from the function, and that the database is trusted. Save the module before running the query again.
Can this function handle a comma inside a phrase?
No. Split treats every comma as a separator. If phrases can contain commas, use a parser that understands your quoting rules or store each criterion in a separate child-table row.




