?
Solved

Trying to open a report with a filter

Posted on 2016-11-23
2
Medium Priority
?
55 Views
Last Modified: 2016-11-23
I have this code in the onclick code of a command button on a form...

    Me.Filter = "ListApptBestAgentBusiness" = -1
    Me.FilterOn = True
    
    DoCmd.OpenReport "rptListingAppointmentsSet", acViewPreview, "", "", acNormal

Open in new window


The report is supposed to be displaying only the records where ListApptBestAgentBusiness is True

But it is displaying all records and not filtering.  Thoughts?
0
Comment
Question by:SteveL13
[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
2 Comments
 
LVL 38

Accepted Solution

by:
PatHartman earned 2000 total points
ID: 41899322
You are applying the filter to the form that is opening the report, not the report itself.  The report isn't even open yet.  The OpenReport method has two arguments.  One for a filter and the other for a where clause.  The Where clause is more efficient if your BE is connected to a RDBMS since it returns only the selected records and so can minimize network traffic.  The filter option returns ALL records requested by the report's RecordSource and then filters them locally.  So, depending on the size of the recordset the Where clause could save a lot of time.  Personally, I always use the Where Clause regardless of what type of tables I am connected to.

DoCmd.OpenReport "rptListingAppointmentsSet", acViewPreview, , "ListApptBestAgentBusiness = -1", acNormal
0
 

Author Closing Comment

by:SteveL13
ID: 41899335
Perfect.  Thank you.
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Suggested Courses

765 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