Others

Fix Customer and Date Criteria in a Microsoft Access Union Query

Natalie TaylorNatalie Taylor Nov 20, 2026 869 views

Question details

Correct customer-name and date criteria in an Access union query that returns unexpected profitability percentages.

Fix Customer and Date Criteria in a Microsoft Access Union Query
Product
Microsoft Access
Device & OS
not provided
Scenario
The user wants to filter a union query for two customer names and specified report dates, and may also need a separate query for other customers.
Observed behavior
Profitability percentages are incorrect after customer-name and date filters are added.
Before you start

Open the query in Access and identify each SELECT statement that needs the customer and date filters. Confirm whether RptDateStart and RptDateEnd should match the entered dates exactly or whether you need a date range instead.

Solution 1Recommended

Use IN to apply customer and date criteria together

Use IN to match either customer name while applying both date conditions to every matching row.

In Access SQL, AND is evaluated before OR. Without parentheses, date conditions may apply to only one of the customer-name alternatives.

1
Open SQL View

In the Access Navigation Pane, right-click the union query and select SQL View.

2
Update the WHERE clauses

In each applicable SELECT statement, use: WHERE CustomerName IN ('MERCURY PLASTICS OF', 'MERCURY PLASTICS, IN') AND RptDateStart = [Enter Start Date] AND RptDateEnd = [Enter End Date]. Keep the UNION structure and any other needed criteria intact.

3
Run and check the results

Select Run, enter the requested dates, and check the returned customer rows and profitability percentages against the source data.

Use IN to apply customer and date criteria together
Exact date matches: The example matches RptDateStart and RptDateEnd exactly. If the fields contain time values or the intended filter is a date range, adjust the comparisons to match the data and reporting requirement.
Free Microsoft Office alternative

Review Access Query Results in WPS Spreadsheets

WPS Office is a free, lightweight Office alternative with a familiar interface and Microsoft Office format compatibility. Export Access query results to a spreadsheet to review them in WPS; WPS does not fix or run the Access union query itself.

Review exported customer and profitability data in WPS SpreadsheetsOpen and edit Microsoft Excel XLSX files for easy migrationUse a familiar spreadsheet interfaceWork with a free, lightweight office suite
microsoft office alternative - wps office

Frequently Asked Questions

Why did adding OR change the query results?

Access evaluates AND before OR, so an ungrouped OR can let one customer condition bypass the date criteria. Use CustomerName IN (...) or enclose the customer conditions in parentheses before adding AND date conditions.

Can I use OR instead of IN for the two customers?

Yes. In each applicable WHERE clause, use (CustomerName = 'MERCURY PLASTICS OF' OR CustomerName = 'MERCURY PLASTICS, IN') AND RptDateStart = [Enter Start Date] AND RptDateEnd = [Enter End Date].

Does NOT IN include records with a blank customer name?

It does not include Null customer names. To include them, group the condition as (CustomerName NOT IN (...) OR CustomerName IS NULL) and then add the date criteria with AND.

What if the profitability percentages are still wrong?

In SQL View, check the filters in every applicable SELECT and compare the returned rows with the source data. Also review whether UNION removes duplicate rows and whether the profitability calculation uses the intended totals.

Can WPS Office run the Access union query?

No. Edit and run the union query in Microsoft Access. To review the results in WPS Spreadsheets, export them from Access to an Excel file and open that file in WPS.