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
579 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 35

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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
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 35

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 35

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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

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…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

778 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