Solved

OpenReport Method's Where Criteria

Posted on 2002-05-07
4
485 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

864 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

21 Experts available now in Live!

Get 1:1 Help Now