Use NOT and AND to Exclude Multiple Criteria in an Access Query
Question details
Exclude records only when State is Texas and Code is BKCL in a Microsoft Access query.

- Product
- Microsoft Access
- Device & OS
- not provided
- Scenario
- A query should retain Texas records with other codes and non-Texas records with code BKCL.
- Observed behavior
- Using AND between two not-equal conditions excludes records that match either condition, removing more records than intended.
Identify the table or query and confirm the names of its State and Code fields. Check whether either field can contain Null, because standard comparisons do not automatically retain every record with missing values.
Exclude the Texas and BKCL Combination in Access SQL
Use NOT around both conditions to exclude only records that match the specified combination.
In Access, open the query in Design View, then select View > SQL View. To create a query, select Create > Query Design and switch to SQL View.
Use this query, replacing YourTableName with the actual table name: SELECT * FROM [YourTableName] WHERE NOT ([State] = "Texas" AND [Code] = "BKCL");
Select Run and check that Texas/BKCL records are excluded while Texas records with other codes and non-Texas records with BKCL remain.

Use OR With Two Not-Equal Conditions
Use an equivalent expression if you prefer to write the criteria without NOT.
Review Exported Access Data in WPS Spreadsheets
WPS Office is a free, lightweight Office alternative with a familiar interface for working with exported data. Export an Access query to Excel, then open the workbook in WPS Spreadsheets for an easy transition to spreadsheet review. WPS does not run or fix Access queries.

Frequently Asked Questions
Why does using AND between two not-equal conditions remove too many records?
WHERE [State] <> "Texas" AND [Code] <> "BKCL" requires both fields to differ from the specified values. It therefore excludes every Texas record and every BKCL record, rather than only the Texas/BKCL combination.
Can I use OR instead of NOT in the Access query?
Yes. For non-Null values, WHERE [State] <> "Texas" OR [Code] <> "BKCL" is equivalent to NOT ([State] = "Texas" AND [Code] = "BKCL").
How can I keep records with a missing State or Code?
In SQL View, add explicit Null checks: WHERE [State] Is Null OR [Code] Is Null OR NOT ([State] = "Texas" AND [Code] = "BKCL").
How do I review the Access query results in WPS?
In Access, export the query results to an Excel workbook using the External Data export options. Open the resulting XLSX file in WPS Spreadsheets; the Access query itself must still be created and run in Access.




