Fix Access DAO Recordset Query Error 3075 for Text Fields
Question details
The user is attempting to open a second DAO recordset using a text value (ProductCode) from a primary recordset, but encounters a syntax error.
- Product
- Microsoft Access
- Device & OS
- not provided
- Scenario
- Dynamically building an SQL SELECT statement in VBA to filter a DAO recordset using a text variable.
- Observed behavior
- The VBA code triggers run-time error 3075 ('Syntax error (missing operator) in query expression'), preventing the recordset from opening.
Verify the exact data type of the field you are querying (e.g., Text, Number, or Date) in your table design, as this determines the necessary syntax characters required in your SQL statement.
Enclose the Text Variable in Single Quotes
Directly resolves the syntax error by adding the required SQL single quotes for text string criteria.
In SQL syntax, text string values must be enclosed in single quotation marks. When concatenating variables into a SQL string in VBA, failing to wrap text variables in quotes causes Access to read the text as an operator or field name, resulting in Error 3075.
In Microsoft Access, press ALT + F11 to open the VBA Editor and locate the module containing your DAO recordset code.
Find the line of code that reads: Set rsStock = db.OpenRecordset("SELECT * FROM tblStock WHERE ProductCode = " & rsExpInv!ProductCode)
Modify the SQL string concatenation to wrap the variable in single quotes. Change it to: Set rsStock = db.OpenRecordset("SELECT * FROM tblStock WHERE ProductCode = '" & rsExpInv!ProductCode & "'")
Save your VBA module and execute the code again to confirm that the run-time error is resolved.
Use Parameterized Queries for Production Code
Improves code security and completely avoids string concatenation and quote escaping issues.
Looking for a Free and Lightweight Office Suite?
While advanced database queries require Microsoft Access, for all your daily document, spreadsheet, and presentation tasks, WPS Office offers a free, lightweight, and highly compatible alternative. Enjoy a familiar interface and seamless workflow without the heavy subscription fees.
- 1. Download the Installer: Visit the official WPS website and download the free WPS Office installer.
- 2. Install WPS Office: Run the setup file and follow the quick on-screen instructions to install the suite on your device.
- 3. Open Existing Office Files: Launch WPS Office to instantly open, edit, and save your existing Microsoft Word, Excel, and PowerPoint files with perfect formatting.

Frequently Asked Questions
Why do I get error 3075 'missing operator' when querying a number field?
Number fields do not require quotes in SQL. If you get error 3075 when querying a number, check if your variable is null or empty. An empty variable results in an incomplete SQL string (e.g., WHERE ID = ), which triggers the missing operator error.
How do I format Date criteria in Access SQL?
When filtering DAO recordsets by a Date field, the date value must be enclosed in hash or pound signs (#). For example: WHERE OrderDate = #" & myDateVar & "#.
What happens if my text field contains an apostrophe or single quote?
If your text string contains a single quote, using single quotes as delimiters will prematurely close the string and cause a syntax error. To fix this, use the Replace() function to double up the single quotes: Replace(myString, "'", "''").




