?
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
Medium Priority
?
676 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 38

Accepted Solution

by:
PatHartman earned 2000 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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
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 38

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 38

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

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

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

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

777 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