Solved

How can I switch a report from report view to preview and make sure the report filters are read so that not the full report is opened?

Posted on 2015-01-28
7
593 Views
Last Modified: 2015-01-28
I'm trying to make it so a person can reopen a report in print preview so that they can easily zoom in and out on the report, to make it easier to see. Setting a button to open in print preview locks up navigation so that I can't navigate at all in print preview.

Setting the button code to

DoCmd.Close acReport, "YourReportNameHere"
     DoCmd.OpenReport "YourReportNameHere", acViewPreview

reopens the report in print preview without locking up, but it doesn't read the report conditions that were used to open the report, so the full report opens - unfiltered.

I'm disabling the ribbon and menus, so those are not options.

This report opens from a form. On the form are 4 combo boxes. The macro builder behind the button has the conditions set to look through the 16 different scenarios of combo boxes being null or not null and then opens the report in report view based on which condition matches.

A manager wants to be able to zoom in to see the report better. That is the end goal.

How can I open the report in print preview that will acknowledge the selected condition and allow for navigation in the preview mode?

Or, if you have another user friendly method of zooming in, while preserving the selected report condition, that would be helpful.
0
Comment
Question by:David Bigelow
  • 3
  • 2
  • 2
7 Comments
 
LVL 36

Accepted Solution

by:
PatHartman earned 500 total points
ID: 40575785
In the OpenReport method that opens the report originally, don't you have filters or a where argument?  You just need to use the same criteria opening the report the second time.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 40575813
<No Points wanted>

Yes,...as in your previous question, ...it is not clear how you are opening the filtered report initially (in Report View).
Go with Pat's suggestion and filter the report in the "Open" Code, ...both times.

For example, put code like this on the original Report open in Report View:
Docmd.OpenReport "YourReport",acViewReport ,,"ID=" & txtID)

...Then do this on the code to reopen the Report in Print Preview:
DoCmd.Close acReport, "YourReportNameHere"
Docmd.OpenReport "YourReportNameHere",acViewPreview ,,"ID=" & txtID)

I am sure Pat can help you from here on out, ...so I will step aside to avoid confusion.

JeffCoachman
0
 
LVL 1

Author Closing Comment

by:David Bigelow
ID: 40575978
"...use the same criteria...."

Since I didn't want to retype 16 conditions, each referencing 4 combo boxes as null or not null, I copied the Run Report button (which already had that embedded macro and 16 conditions) from the form with the combo boxes to the Report header.

I then changed the view in the embedded macro settings to Print Preview

But that wouldn't run the report based on the combo box conditions since the form and it's combo boxes were not opened.

So then I put in an action above the 16 lines to open the form first.

That opened the report in preview, and filtered, but navigation was still locked, as in my previous angst.

So then I used Pat's idea to close the report first. I put another action above the open form action to close the report.

That opened the report: filtered, in print preview, and navigable. Yahoo! Oh, wrong forum, "Experts-Exchange!"

Final embedded macro looks like this

Close Report
Open form
16 lines of conditions
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 40576184
...
I see, ...
In a typical situation, this would be done in code, where you can type the 16 conditions and define them as a Variable.
    "strFilter"
Then you can "Call" this variable in your code:
Docmd.OpenReport "YourReport",acViewReport ,,strFilter)
Now you can insert this criteria in as many places as you want, ...without the need to retype anything.
You can modify the filter in only one place and the changes will be reflected anywhere the variable is used.
Just FYI
;-)
Jeff
0
 
LVL 36

Expert Comment

by:PatHartman
ID: 40576199
One more reason to avoid macros.

There is a button on the ribbon to convert macros to code if you want to get your feet wet.
0
 
LVL 1

Author Comment

by:David Bigelow
ID: 40576222
Thanks for the strFilter note!

Ah, yes, I found the Convert Form's Macros to Visual Basic button. I was thinking the macro itself had to be open and couldn't find an option there. That will be useful. I'm taking a VBA class next month.
0
 
LVL 36

Expert Comment

by:PatHartman
ID: 40576413
The macros don't write very good code and the code in the embedded macros is worse than what they wrote in the early days when I first learned to use Access but I did get my start with VBA by writing simple macros and converting them to code.  Then I switched to the Access Cookbook.  It has a version 2 but hasn't been updated since A2003.  No matter, VBA is pretty much the same.  The only thing is that some of the recipes in the cookbook are no longer necessary because MS got the message and implemented them natively.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

830 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