Docmd.OpenReport

  • Thread starter Graeme Richardson
  • Start date
G

Graeme Richardson

Is it possible to read the WhereCondition argument in the Report_Open event?

DoCmd.OpenReport "rptAddressLabel", acViewPreview, , "uidMember = 1234"

I want to be able to change the condition (to "uidMember = 5678" say) or
discard it all together (i.e. print all address labels), while retaining the
ability to Cancel the report. I have a dialog where the user can enter
criteria. The Me.Filter value is "" in the Report_Open event.
I'm trying to do this from an object point of view. I give the report some
information and it does the rest itself. Basically, I'm trying to get an
OpenArgs property for a report.
I see that the Report_Activate event gives the Me.Filter value.
Unfortunately, the report is committed by that stage.

Please, no global variables.

Thanks, Graeme.
 
A

Allen Browne

You should be able to read the WhereCondition in the Filter property of the
report. Unfortunately, Access does not maintain the FilterOn property
correctly for reports, so you don't know if this is the current filter or
merely an artifact from a previous run.

Is there another approach you would consider? In Access 2002 or 2003, you
use OpenArgs instead of the WhereCondition, and read/modify/apply it in
Report_Open. It would even be possible to save the report unbound, and
assign it a RecordSource in Report_Open once you have decided what's needed.
 
P

Peter De Baets

There's an openargs property for reports in Access 2002 and above.

Otherwise just use a global variable. What is your opposition to using
them? Just create a new module (call it "global variables") and put
the following text in there under the "Option ..." line:

Public gReportOpenargs as String

Then call your report like so:

gReportOpenargs = "my openargs parm"
DoCmd.OpenReport "rptAddressLabel", ...

Then in your report OnOpen event procedure use "gReportOpenargs" just
as you would "Me.Openargs".

Hope this helps,

Peter De Baets
Peter's Software - MS Access Tools for Developers
http://www.peterssoftware.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

OpenReport & OpenArgs 2
Where Condition 3
Filter question 6
Printing and export 3
OpenArgs and reports 3
Combining/Merging Reports 2
Me.Filter on Subreport does not work? 1
data fields not found???? 2

Top