OpenReport where condition with openargs

  • Thread starter Thread starter marjweir
  • Start date Start date
M

marjweir

When I use openargs with a "Where" condition in an OpenReport command
the "Where" criteria do not appear in the called reports Filter
Property. When I omit the openargs, it seems to work. I am confident
of the syntax of the "Where" condition statement, as it has worked in
other combinations of parameters.

Is there anything inherently incompatible between the "where" and the
"openargs" parameters? I am also opening the report with acdialog.
See example below.

dim strcriteria as string
dim stdocname as string
dim stfilteron as string
strcriteria = "[Active] = True" 'or false or ""
stdocname = "Case Managers List Short"
stfilteron = "0" ' or "-1" depending on the entries that control
this
'all these variables are being set correctly in this part of the
program

DoCmd.OpenReport stdocname, acViewPreview, ,strcriteria, acDialog,
stfilteron

'When I run the program and step through the process in the form_open
of the report, I see that the stfilteron value in openargs is set
accurately, but there is no content in Me.Filter.
I am trying to test the content of the Filter Property and insert
content into a descriptive label in the Page header section to display
the criteria more gracefully than just printing the Me.Filter in that
label. In any event the me.filter property does not seem to be
changing the way I would expect it to.
When is that property changed, if at all?
 
This is a bug that's fixed in Access 2007.

Previous versions of Access never maintained the Filter/FilterOn properties
of the report correctly. Other examples here:
Incorrect filtering
at:
http://allenbrowne.com/bug-02.html

If you can't switch to A2007, you may be able to work around the issue by
setting public variables.

Not sure exactly what you are doing, but I always call my own
OpenTheReport() function instead of OpenReport:
http://allenbrowne.com/AppPrintMgtCode.html#OpenTheReport

It addresses several issues, e.g.:
- setting a return value rather than generaing errors if the report doesn't
open,
- closing the report if already open so the filter is applied correctly,
- setting one of the user's specific printer if required, and
- passing a user-readable description of the filter in OpenArgs.
 
Back
Top