Solved

OpenReport Method's Where Criteria

Posted on 2002-05-07
4
492 Views
Last Modified: 2008-02-26
I am trying to use the where conditions in the DoCmd.OpenReport method in VB.  I'm having the user put in values in combo boxes on a form (three combo boxes; Folio, LastName and Planner), and then limiting the records on the report to those that have those values.  I am experimenting with one value right now and it's not working.

Here is what I have:

DoCmd.OpenReport stDocName, acPreview, , [FOLIO] = _ [Forms]![frmActivityReport]![FOLIO]

stDocName is the variable name for the report.  Folio is the name of a field in the report's underlying query, and the name of a combo box on a form.  When it runs this code, it opens the form and displays all the records from the query.

Is there some setting that the report must be set to, like the FilterOn, or something?  And will I have any isues when I use more than one parameter in the where condition (when the user puts in a Folio number AND a LastName).  

Any help would be appreciated,

Brendan
0
Comment
Question by:dwyerb
[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
  • 3
4 Comments
 
LVL 3

Expert Comment

by:SE081398
ID: 6993979

try this

DoCmd.OpenReport stDocName, acPreview, , "[FOLIO] = " &[Forms]![frmActivityReport]![FOLIO]
0
 
LVL 3

Accepted Solution

by:
SE081398 earned 100 total points
ID: 6993985
sorry

it's like this.

DoCmd.OpenReport stDocName, acPreview, , ,"[FOLIO] = [Forms]![frmActivityReport]![FOLIO]"
0
 

Author Comment

by:dwyerb
ID: 6994001
SE
OUTSTANDING!  Works perfectly.

Can I ask a couple of questions?  Why does it need the quotation marks?  I use SQL a lot in other software, so I'm a little familiar w/ it.  And I didn't see anything in the documentation about quotation marks.

Also, will this work with more than one criteria?
0
 
LVL 3

Expert Comment

by:SE081398
ID: 6994864
Why does it need the quotation marks?  
the argument is a string.  therefore it must be passed as a string.

Yes it will work with several criteria.  however if you are wanting to filter the form based on criteria expressions, there are better ways of doing it.

I like to use the recordsource property.  this way I create an sql statement and set the propery to that sql.  this way the form opens up based on the sql of the recordsource.  this allows a little more flexibility when dealing with many different possibilities.  
0

Featured Post

Ready to get started with anonymous questions?

It's easy! Check out this step-by-step guide for asking an anonymous question on Experts Exchange.

Question has a verified solution.

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

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
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…
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.

626 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