Solved

Query Sytax

Posted on 2014-02-14
2
105 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
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…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

757 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now