Solved

Display full report but only print page 1 & 2

Posted on 2014-09-03
13
549 Views
Last Modified: 2014-09-04
Access report with multiple subreports, displays about 15 pages of data. Customers usually print the first 2 pages and the other 13 pages are thrown away. My customers do not want the report changed, they like to see the information displayed on screen but are printing out the whole report.(instead of using the print dialog and selecting page 1 to 2)

To save paper I want to only print out page 1 & page 2 when the user prints the report. Is there a way to control this via a vba onprint statement? Please post the code?
0
Comment
Question by:Dalexan
  • 5
  • 5
  • 2
  • +1
13 Comments
 
LVL 26

Assisted Solution

by:MacroShadow
MacroShadow earned 250 total points
ID: 40302976
Use the following command to print the report:
DoCmd.PrintOut acPages, 1, 2

Open in new window

0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 40303044
You might want to consider supplying a custom button to do that.  That will give the user what they want usually but still retain the possibility to print the complete report should it be required occasionally.
0
 

Author Comment

by:Dalexan
ID: 40303426
How can I capture the print command instead of creating a button.

Public Sub PrintReport()
On Error GoTo Err_PrintReport

    DoCmd.OpenReport "REPORT: Site / Campaign / VoterInfo", acViewPreview
    DoCmd.PrintOut acPages, 1, 2

Exit_PrintReport:
    Exit Sub

Err_PrintReport:
    MsgBox Err.Number & " (" & Err.Description & ") in procedure PrintReport"
    Resume Exit_PrintReport

End Sub
0
 
LVL 26

Accepted Solution

by:
Nick67 earned 250 total points
ID: 40303887
"Is there a way to control this via a vba onprint statement?"
"How can I capture the print command instead of creating a button."

If you click on the MS-supplied printer icon button on a toolbar/ribbon, the whole report will be printed.
You cannot intercept that call via VBA.
If you are using Access 2007 and greater, you can customize the Ribbon (which has a fairly steep learning curve) to eliminate that button and then replace it with a custom button(s) of your own on the Ribbon.  MS makes it ridiculously difficult, but not impossible, to intercept the commands issued by Ribbon buttons, through Ribbon customizations, and replace them with your own -- but I wouldn't go there because it is incredibly hard to do and get right for a single specific report.  It can be a little easier to do so universally for all reports in an application, but even then MS clearly has made it tough for developers to monkey with their sainted FluentUI.

Best practices usually dictate that the NavPain and/or database window are hidden from end-users.  The usual method of opening reports is to click a button on a form.  The form and the code behind the button then supply any parameters and OpenArgs that the report may then need.  It is suggested that in this case you should have one button labeled 'Preview Report' and another labeled 'Print First Two Pages' for your users.

In general, you should not have your users using the MS-supplied controls for much of anything -- because YOU cannot exert influence over what those controls do.  If you condition users to use the MS-supplied controls, and then requirements change so that their innate actions are not what you want, you are then screwed.  Controls that YOU place on forms are under your complete command, and you can change how they behave a circumstances dictate.

You could take the time to try to learn how to customize the Ribbon.  A better use of your time will be in honing your app so that users don't need to, and aren't tempted to, use the MS-supplied UI for anything, and re-educating your users.

That's my advice, anyway.

Nick67
0
 

Author Comment

by:Dalexan
ID: 40303929
Thanks, this is good advice Nick. We're working on abandoning all microsoft tech within the next year so I'm abandoning this idea to intercept the print command.
0
 
LVL 26

Expert Comment

by:Nick67
ID: 40303950
May I ask why you are abandoning MS and what you hope to move to?
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)

 

Author Comment

by:Dalexan
ID: 40303994
The litany of microsoft versions has me lost in a giant list of what system supports what version. We're already developing using rails and moving our reporting tools to an in house built MVC/ruby framework. Much easier to support without all the MS bullshit.
0
 
LVL 26

Expert Comment

by:Nick67
ID: 40304057
I don't have much faith in anyone right now.  Firefox and their rapid rev'ving makes them an unsuitable platform--but everyone seems to have caught that disease.  Very few have understood that the slow decline of XP and old verisons of IE indicate that a VERY large group of folks want a platform that remains stable and unchanging for a decade or more.  Rapid change is not a bonus in a mature product.  And the Cloud is not a intelligent option for most because of the stupidly high cost of high-speed upload capability.  'Let's back everything up to the Cloud!'  'Great, you try and push a terabyte up to the Cloud, and tell me how long that'll take, and if and when you get it up there, tell me how long it'll take to suck it back down in a DR situation'

Sigh.

Maybe I am an old dinosaur.
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 40304080
>>And the Cloud is not a intelligent option...
Unless the stuff stored there is well encrypted it is not something to trust with confidential information either.

To be honest I suspect lots of people in the software organisations would prefer a slower cycle, but the marketing people need a new product to justify their existence.

ps.  Dinosaurs were around for 150 million years, they were doing something right.
0
 

Author Comment

by:Dalexan
ID: 40304137
Are you also abandoning MS technology's?
0
 
LVL 26

Expert Comment

by:Nick67
ID: 40304236
No...
But the removal of Exchange from the SBS replacements (WIndows Server Essentials) means that things have gotten very pricey and complex (the cheapest solution for 25+ users licensing-wise is to install Windows Server as a hypervisor, and then Windows Server twice as a VM, once as a domain controller and Essentials Experience unit, and once to run Exchange.)  And then you need all the bloody CALs, both Server and Exchange.  Much more expensive.
And...
MS has SharePoint-itis.  I am an Access guy.  There's no need to manage thousands of Word and Excel documents.  That's what Access reports are for :)  MS has left the VBA platform twisting in the wind, in favor of this 'Look ma, no code (only intermediate functionality, but no code!) thing.  They should know from the complete thud that Surface RT devices landed with that the VBA platform is the very thing that continues to drive Office (remember what occurred with that Office for Mac version that had no VBA support?)  But they sure don't talk or act like they know it.

It'll be a lot like the moderate Republican experience -- I didn't leave them, they left me.
0
 

Author Comment

by:Dalexan
ID: 40304282
It'll be a lot like the moderate Republican experience -- I didn't leave them, they left me.
I like it, haha! My girlfriend happens to be a systems analyst for a major government contractor, they use MOSS, she has nothing but bad things to say about it.
0
 
LVL 26

Expert Comment

by:Nick67
ID: 40304399
Nobody has good things to say about SharePoint except MS.
For them, 'It's a growing billion dollar division!'
But for most folks who are in that hell, this site isn't full of jokes
http://paulswider.com/sharepoint-jokes/
It's full of bitter observations of their everyday reality
0

Featured Post

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

758 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