Solved

Query Sytax

Posted on 2014-02-14
2
111 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

The Orion Papers

Are you interested in becoming an AWS Certified Solutions Architect?

Discover a new interactive way of training for the exam.

Question has a verified solution.

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

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

690 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