[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Query Sytax

Posted on 2014-02-14
2
Medium Priority
?
114 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 2000 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

Restore individual SQL databases with ease

Veeam Explorer for Microsoft SQL Server delivers an easy-to-use, wizard-driven interface for restoring your databases from a backup. No expert SQL background required. Web interface provides a complete view of all available SQL databases to simplify the recovery of lost database

Question has a verified solution.

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

We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

810 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