Solved

OpenReport Method's Where Criteria

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

828 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