?
Solved

Query Sytax

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

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

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

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
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.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

765 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