Solved

Query Sytax

Posted on 2014-02-14
2
109 Views
Last Modified: 2014-02-14
I have the following command working to open a report

DoCmd.OpenReport "rGeneralShort", PrintOption, "qRFPUBAL"


Now I wanted to add a filter based on a form selection.  So when I treid the following but I'm getting a run time error 2501... where did I got wrong?


DoCmd.OpenReport "rGeneralShort", PrintOption, "qRFPUBAL", "(((tMain.OfficePU)=[forms]![freportselect]![LocSelect]))"


Thank you.
0
Comment
Question by:thandel
  • 2
2 Comments
 
LVL 61

Accepted Solution

by:
mbizup earned 500 total points
ID: 39859244
Try this (numeric criteria):

DoCmd.OpenReport "rGeneralShort", PrintOption, "qRFPUBAL", "tMain.OfficePU =" & [forms]![freportselect]![LocSelect]

Open in new window


Or this (Textcriteria):

DoCmd.OpenReport "rGeneralShort", PrintOption, "qRFPUBAL", "tMain.OfficePU ='" & [forms]![freportselect]![LocSelect] & "'"

Open in new window

0
 
LVL 61

Expert Comment

by:mbizup
ID: 39859253
Depending on the reports recordsource, you may also need to drop the tMain prefix.
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

827 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question