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

Syntax error (missing operator) in query expression - works for one form but not anot

P: 1
I used this code to successfully run a report on a single record on one table/form but when I applied it to another table/form it comes-up with:

Syntax error (missing operator) in query expression 'FirmName=Smith Management Corporation'.

What am I missing?

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command364_Click()
  2. On Error GoTo ErrHandler
  3. DoCmd.OpenReport ReportName:="FirmSummary", View:=acViewPreview, _
  4. WhereCondition:="FirmName=" & Me.FirmName
  5. Exit Sub
ErrHandler:
Expand|Select|Wrap|Line Numbers
  1. ' Don't show error message if report was canceled
  2.     If Err <> 2501 Then
  3.         MsgBox Err.Description, vbCritical
  4.     End If
  5. End Sub
2 Weeks Ago #1

✓ answered by twinnyfo

Nmadau,

Welcome to Bytes!

You need single quotes in your where clause:

Expand|Select|Wrap|Line Numbers
  1. WhereCondition:="FirmName='" & Me.FirmName & "'"
Please note, you will have to make those straight quotes. I am typing on my iPad and it canít un-curl those quotes.

Hope this hepps!

Share this Question
Share on Google+
2 Replies


twinnyfo
Expert Mod 2.5K+
P: 3,257
Nmadau,

Welcome to Bytes!

You need single quotes in your where clause:

Expand|Select|Wrap|Line Numbers
  1. WhereCondition:="FirmName='" & Me.FirmName & "'"
Please note, you will have to make those straight quotes. I am typing on my iPad and it canít un-curl those quotes.

Hope this hepps!
1 Week Ago #2

NeoPa
Expert Mod 15k+
P: 31,433
As Twinny says, that code cannot possibly work as it stands (See Quotes (') and Double-Quotes (") - Where and When to use them). I suspect you had one that worked which used a numeric field.
4 Days Ago #3

Post your reply

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