[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Trying to open a report with a filter

Posted on 2016-11-23
2
Medium Priority
?
62 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 39

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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
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…
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 …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

656 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