Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 562
  • Last Modified:

Display full report but only print page 1 & 2

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
Dalexan
Asked:
Dalexan
  • 5
  • 5
  • 2
  • +1
2 Solutions
 
MacroShadowCommented:
Use the following command to print the report:
DoCmd.PrintOut acPages, 1, 2

Open in new window

0
 
AndyAinscowCommented:
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
 
DalexanAuthor Commented:
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
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
Nick67Commented:
"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
 
DalexanAuthor Commented:
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
 
Nick67Commented:
May I ask why you are abandoning MS and what you hope to move to?
0
 
DalexanAuthor Commented:
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
 
Nick67Commented:
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
 
AndyAinscowCommented:
>>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
 
DalexanAuthor Commented:
Are you also abandoning MS technology's?
0
 
Nick67Commented:
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
 
DalexanAuthor Commented:
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
 
Nick67Commented:
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

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 5
  • 5
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now