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
570 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 34

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
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
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 34

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 34

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

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.

Question has a verified solution.

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

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
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.

912 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now