Solved

OpenReport Method's Where Criteria

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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

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
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

710 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