Can a report be instructed to print either one or two pages on command? (1 Viewer)

bcmarshall

Registered User.
Local time
Today, 02:16
Joined
Jul 17, 2010
Messages
92
I'm creating a report that is really more or less a receipt. It has fields on it such as name, address, and the like, but it's not a report in the sense of printing a query or table contents. It would only contain data for the customer to whom it's being addressed.

This page is essentially a laid-out page, with company logo, populated fields, blank lines for the customer to fill in bank account info and return to us, etc. I'm just trying to clarify that it's not a straight data list report.

The first page is common to all printings, but there is a second, graphic page, consider it an advertising page, which I only want included with some iterations of the report. That second page has no data fields at all. It's simply a full-page sized graphic.

Can I programmatically tell Access to print only the first page in some instances, and both pages in others?

Any assistance is always greatly appreciated.
 
Last edited:

bcmarshall

Registered User.
Local time
Today, 02:16
Joined
Jul 17, 2010
Messages
92
YESSSSS! That seems exactly what I was hoping for, but I'm wondering if you can help with usage. I'm not actually printing the report, but instead am attaching it as a .pdf to an email.

This is the code I use to output it to a file for attachment. How might that be integrated to work within the restrictions I have?

DoCmd.OutputTo acOutputReport, "QuoteMC", acFormatPDF, "C:\Data\MotorcycleInsuranceQuote.pdf"
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 04:16
Joined
Feb 28, 2001
Messages
27,191
The best way would be to have an event routine in the report that decides based on some external inputs whether or not to include the graphics at all. There is a way to cancel a page though I have not used it myself. If the report doesn't have the page when you create the PDF then your problem is solved.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 02:16
Joined
Oct 29, 2018
Messages
21,474
YESSSSS! That seems exactly what I was hoping for, but I'm wondering if you can help with usage. I'm not actually printing the report, but instead am attaching it as a .pdf to an email.

This is the code I use to output it to a file for attachment. How might that be integrated to work within the restrictions I have?

DoCmd.OutputTo acOutputReport, "QuoteMC", acFormatPDF, "C:\Data\MotorcycleInsuranceQuote.pdf"
Oh, I see. If we continue with the plan to use the PrintOut method, then you can assign a permanent printer to the report - make it the PDF printer. However, perhaps the simplest solution is to simply create a duplicate report and just remove the last page from it. Then, in your code for printing, add a logic to decide which report to print: the full report or the one without the ad.
 

bcmarshall

Registered User.
Local time
Today, 02:16
Joined
Jul 17, 2010
Messages
92
Thank you. Your answer is clearly what I'm looking for. I just have to tweak it for optimum performance under my circumstances.

I greatly appreciate the assistance. Just knowing the DoCmd.PrintOut method is a big help to me.
 

bcmarshall

Registered User.
Local time
Today, 02:16
Joined
Jul 17, 2010
Messages
92
Oh, I see. If we continue with the plan to use the PrintOut method, then you can assign a permanent printer to the report - make it the PDF printer. However, perhaps the simplest solution is to simply create a duplicate report and just remove the last page from it. Then, in your code for printing, add a logic to decide which report to print: the full report or the one without the ad.
That was my go-to correction for this. The second report is always an option, but I'm this nerdy character that wants to do everything the "easy" way even if it takes 10 times longer!

Thanks. That's cheap and dirty and I don't have to worry that way.
 

Users who are viewing this thread

Top Bottom