By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,251 Members | 2,764 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.

MS ACCESS, Syntax error (missing operator)

P: 8
Hi to everyone,

I have the following problem which is producing the following error:

Syntax error (missing operator) in query expression '(CourseNo = CN1863)

This caused from the follOwing being run from a command button on a form. The sync is between the form (Combo box ) and a report (txt field).

DoCmd.OpenReport "RptValidationMainP3_Course1863", acPrintPreview, , "CourseNo = " & Me.CourseNo

The report is based on a table which has many 'CourseNo's', and I want the chosen value from the form combo to filter the records to be printed in the report. i.e select CourseNo '1863' via the combo box on the form (with other fields input by the user) and then clicking the command button opens the report filtered to the combo box value.

My apologies if i've been a bit long winded describing this, and hope that there is enough here to show my problem.

Any assistance would be really appreciated.

My Thanks

Dave
Mar 3 '08 #1
Share this Question
Share on Google+
6 Replies


Expert Mod 2.5K+
P: 2,545
...I have the following problem which is producing the following error:
Syntax error (missing operator) in query expression '(CourseNo = CN1863)
...
DoCmd.OpenReport "RptValidationMainP3_Course1863", acPrintPreview, , "CourseNo = " & Me.CourseNo
Hi Dave. This problem crops up fairly frequently in referring to string values, and arises because you are missing two quote marks from the filter statement. This should be:
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenReport "RptValidationMainP3_Course1863", acPrintPreview, , "CourseNo = '" & Me.CourseNo & "'"
Without the quote marks Access is trying to interpret the course name as a field name or operator, without success.

Add the quote marks in as shown and the DoCmd should be OK.

-Stewart
Mar 3 '08 #2

P: 8
Hi Dave. This problem crops up fairly frequently in referring to string values, and arises because you are missing two quote marks from the filter statement. This should be:
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenReport "RptValidationMainP3_Course1863", acPrintPreview, , "CourseNo = '" & Me.CourseNo & "'"
Without the quote marks Access is trying to interpret the course name as a field name or operator, without success.

Add the quote marks in as shown and the DoCmd should be OK.

-Stewart

Hi Stewart,

Works a treat!. This is one thing i will pop in my good gen folder. Many many thanks, and I am smiling like a 3 year old kid!!

with best wishes, Dave
Mar 3 '08 #3

Expert Mod 2.5K+
P: 2,545
Hi Stewart,

Works a treat!. This is one thing i will pop in my good gen folder. Many many thanks, and I am smiling like a 3 year old kid!!

with best wishes, Dave
Very glad to have been able to help, Dave.

Regards

Stewart
Mar 3 '08 #4

P: 9
I was running into this same problem and it turned out that I was missing the quotation marks as susggested. This got me past that hurdle however I know have a new problem.

Now when I go to open the report I am present with a message box asking me to input the value that is referenced in the filter.

Anyone with ideas?
Aug 15 '08 #5

Expert Mod 2.5K+
P: 2,545
Hi jghouse. We'd need to know a bit more about your problem before we can answer it, and as it really does not relate to this particular thread it would be better to start a new discussion thread for your current difficulty.

If you could please do so, posting the code that is used to open your report, it would be much appreciated.

Thanks

Stewart

...Now when I go to open the report I am present with a message box asking me to input the value that is referenced in the filter.
Aug 15 '08 #6

P: 9
Hi jghouse. We'd need to know a bit more about your problem before we can answer it, and as it really does not relate to this particular thread it would be better to start a new discussion thread for your current difficulty.

If you could please do so, posting the code that is used to open your report, it would be much appreciated.

Thanks

Stewart
Stewart,

Thanks to your attention on this. After a night away from it I realized an unbelievably stupid error. My issue is not fixed but this thread was helpful in oslving my original one. Thanks again for all you do.
Aug 15 '08 #7

Post your reply

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