By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,454 Members | 3,103 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,454 IT Pros & Developers. It's quick & easy.

Run Time Error '3075' Syntax error (comma) in Query

P: 46
I have narrowed it down to [Field Trip Selection log].Driver) =" & Me![Employee]. My employees do have a comma in their names. Thank you for your help.


Error Code says:
Run-time error '3075'

Syntax error(comma) in query expression '(((Field Trip Selection log].Driver )= Thomas, Bob)And (([Field Trip Selection Log].[Yes]=False) And (([Field Trip Selection log]/[No] = False))'.




Expand|Select|Wrap|Line Numbers
  1. ssql = ssql & "SELECT [Field Trip Selection log].[Pending Bookings ID], [Field Trip Selection log].Driver, [Field Trip Selection log].Note, [Field Trip Selection log].[Log ID], [Field Trip Selection log].[Yes], [Field Trip Selection log].[No] "
  2. ssql = ssql & "From [Field Trip Selection log] "
  3. ssql = ssql & "WHERE ((([Field Trip Selection log].Driver) =" & Me![Employee] & ")And (([Field Trip Selection log].[Yes]) = False) And (([Field Trip Selection log].[No]) = False)) "
  4. ssql = ssql & "ORDER BY [Field Trip Selection log].[Log ID];"
  5. Set db1 = CurrentDb.OpenRecordset(ssql)
Jul 13 '15 #1

✓ answered by NeoPa

Well asked question. Easy to answer :-)

Your problem here is that SQL expects string literal values (Such as the employee's name.) to be surrounded in quotes ('). That is how it recognises when it's dealing with literal data rather than instructions. More on that at Quotes (') and Double-Quotes (") - Where and When to use them.

If you're still curious then add this line after your line #4 :
Expand|Select|Wrap|Line Numbers
  1. Debug.Print ssql
When you see the result in the Immediate Pane (Use Ctrl-G to open that.) you should follow through what you see and realise what it's trying to do. If not, and you'd like help interpreting it as SQL would, post the full value in here and we'll help you with it.

Share this Question
Share on Google+
1 Reply


NeoPa
Expert Mod 15k+
P: 31,494
Well asked question. Easy to answer :-)

Your problem here is that SQL expects string literal values (Such as the employee's name.) to be surrounded in quotes ('). That is how it recognises when it's dealing with literal data rather than instructions. More on that at Quotes (') and Double-Quotes (") - Where and When to use them.

If you're still curious then add this line after your line #4 :
Expand|Select|Wrap|Line Numbers
  1. Debug.Print ssql
When you see the result in the Immediate Pane (Use Ctrl-G to open that.) you should follow through what you see and realise what it's trying to do. If not, and you'd like help interpreting it as SQL would, post the full value in here and we'll help you with it.
Jul 14 '15 #2

Post your reply

Sign in to post your reply or Sign up for a free account.