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
560 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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

707 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

18 Experts available now in Live!

Get 1:1 Help Now