ACC2000: changing report .Filter does not work

  • Thread starter Thread starter A Man
  • Start date Start date
A

A Man

I'm still working on issues in earlier threads. When I use code to
change my report's .Filter and set .FilterOn to true, I get no records.
When I manually go to the report design, change the .Filter and
..FilterOn, I also get no records.

Here's the code I use to change .Filter via code:

sWhere = "[cus_no] = '" & sCustnum & "'"
DoCmd.OpenReport sReportname, acViewDesign ' Must come before "set rpt"
Set rpt = Reports(sReportname)
rpt.Filter = sWhere
rpt.FilterOn = True
DoCmd.Close , , acSaveYes
DoEvents ' Allow Access to save report.


What's wrong?
Why is Access ignoring the .Filter property even though .FilterOn is
True (or Yes in the property box).
 
Why are you doing this the hard way. Why not just use

sWhere = "[cus_no] = '" & sCustnum & "'"
Docmd.OpenReport sReportName,acViewPreview,,strWhere

--
John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 
Why are you doing this the hard way. Why not just use

sWhere = "[cus_no] = '" & sCustnum & "'"
Docmd.OpenReport sReportName,acViewPreview,,strWhere
Sorry. In a previous thread I mentioned I have to update the
recordsource, save the report, and create a PDF (one PDF file for each
customer, using the Leblans code), thus I cannot use the
Docmd.openreport, since I do not want to preview the report or print it.
 
As a side note, when I go to the report in design mode, I enter this for
the .Filter:
[cus_no] = '000000080000'

That is a valid field name and customer number. I double checked both.
But I still get no records when I do a report preview. FilterOn is Yes
in the Properties window.

In the Help, About box the version says "Access 2000 (9.0.2720)". I
don't see a service pack listed, do I need one to resolve a report
filter bug?

I'm having a similar problem as posted on 11/13/07 to this same
newsgroup. The .Filter property forces the report to return no records.


Thanks.
 
Back
Top