Solved

OpenReport Method's Where Criteria

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
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…

759 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