How To Determine View Mode from inside a Report

D

Don Nablo

I have a report which is opened via a docmd.openreport call. From this call
you can pass a view (acViewDesign, acViewNormal, or acViewPreview) type...

Is there a way to determine from inside the opened report, which view type
was requested?

As an example:
From External System
objAccess.DoCmd.OpenReport "someReport", prtPrev, , where

From Open event on the Report

I would like to say
if me.Viewmode = acViewPreview then
docmd.openreport "OtherReport",acViewPreview,, some filter
else
docmd.openreport "OtherReport",acViewNormal,, some filter
end if
 
A

Allen Browne

No. The view mode never reaches the report.

If this is Access 2002 or 2003, you could use the OpenArgs.

Otherwise you may be messing with setting flags in the report's Activate
event, since that fires for a preview but not for a print. That's probably a
bit late though.
 
D

Don Nablo

Thanks. That may work in some situations... I have the same issue with the
filter. Once you pass it via a docomd you can't examine or override it in
the report.

Right now my work around is to just have the calling program set a global
variable in access with what was sent
so I execute the following:
objAccess.run "SetFilter", where, prtPrev

Where "setFilter" is a public sub an access module.

The the report will look at the global variable and decide what to do....
 
A

Allen Browne

That's probably the best way to handle the filter.

Access does not maintain the FilterOn property of reports reliably. You
should be able to test in this the report's events (like you can for forms),
but it does not work property, so setting your own filter is not a bad idea
even though it does mean the report has to reload again after it opens.
 

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

Top