My original contact to the Forum was at
http://www.access-programmers.co.uk/forums/showthread.php?t=291003&highlight=HideBlankColumns
I initially contacted the forum regarding a Sample Database to Hide Columns on a Report
Located at http://www.access-programmers.co.uk/forums/showthread.php?t=232405
CJ_London and pbaldy pointed out some issues I was having with the original Sample Database.
That resolved, I was able to implement the code into my Report.
Now that the report appears with all the Blank Columns excluded properly, in Print Preview, the Paper has significant white space on the right and I would like to change the Paper Size from Legal to Letter. Getting the Report to Print on the smaller Letter size paper with empty columns removed, was the entire purpose of implementing the Code and subReport into the Main Report Header.
Unfortunately, I am unable to figure out a way of changing the paper size once the Main Report starts executing the code in the OnFormat Event of the Report Header. I tried everything I could think of.
While I can change the Page with the code below, it actually doesn’t get changed until I close the Report and reopen it. At that point the Printer Paper may be the wrong size for the next set of Data being printed.
I guess I could open a new Private Sub or Macro before the Main Report opens and reset the Paper to acPRPSLegal on the Main Report to process the next set of data, but haven’t attempted to do that because I’m getting an Error when the Main Report is Printed out of the Print Preview view. It only happened when I have removed Blank Columns on the Report. It does not happen when all the columns are filled in and the Report is going to be printed on the Legal Size paper.
The Error I’m getting is:
‘ A custom macro in this report failed to run and is preventing the report from rendering’
This the Code I tried to use to change the Page Size, it doesn’t work on the current iteration of the Report.
Private Sub Report_Page()
If Me.TestLetterSize = "yes" Then
Reports!RptCustJobDetails.Printer.PaperSize = acPRPSLetter
Reports!MainReport.Printer.ItemSizeWidth = 15120 ‘ 10.5 inches, in Twips, for Letter, minus Margins
DoCmd.Save acReport, "MainReport" ‘ this ends up saving it for the next Report, but not the current
Else
Reports!RptCustJobDetails.Printer.PaperSize = acPRPSLegal
Reports!RptCustJobDetails.Printer.ItemSizeWidth = 19440 ’13.5 inches, in Twips for Legal, minus Margins
End If
End Sub
My research has now let me to believe that there no easy way of doing this.
If anyone has any good ideas about how to resolve this please let me know.
Thank you in advance for your help.
http://www.access-programmers.co.uk/forums/showthread.php?t=291003&highlight=HideBlankColumns
I initially contacted the forum regarding a Sample Database to Hide Columns on a Report
Located at http://www.access-programmers.co.uk/forums/showthread.php?t=232405
CJ_London and pbaldy pointed out some issues I was having with the original Sample Database.
That resolved, I was able to implement the code into my Report.
Now that the report appears with all the Blank Columns excluded properly, in Print Preview, the Paper has significant white space on the right and I would like to change the Paper Size from Legal to Letter. Getting the Report to Print on the smaller Letter size paper with empty columns removed, was the entire purpose of implementing the Code and subReport into the Main Report Header.
Unfortunately, I am unable to figure out a way of changing the paper size once the Main Report starts executing the code in the OnFormat Event of the Report Header. I tried everything I could think of.
While I can change the Page with the code below, it actually doesn’t get changed until I close the Report and reopen it. At that point the Printer Paper may be the wrong size for the next set of Data being printed.
I guess I could open a new Private Sub or Macro before the Main Report opens and reset the Paper to acPRPSLegal on the Main Report to process the next set of data, but haven’t attempted to do that because I’m getting an Error when the Main Report is Printed out of the Print Preview view. It only happened when I have removed Blank Columns on the Report. It does not happen when all the columns are filled in and the Report is going to be printed on the Legal Size paper.
The Error I’m getting is:
‘ A custom macro in this report failed to run and is preventing the report from rendering’
This the Code I tried to use to change the Page Size, it doesn’t work on the current iteration of the Report.
Private Sub Report_Page()
If Me.TestLetterSize = "yes" Then
Reports!RptCustJobDetails.Printer.PaperSize = acPRPSLetter
Reports!MainReport.Printer.ItemSizeWidth = 15120 ‘ 10.5 inches, in Twips, for Letter, minus Margins
DoCmd.Save acReport, "MainReport" ‘ this ends up saving it for the next Report, but not the current
Else
Reports!RptCustJobDetails.Printer.PaperSize = acPRPSLegal
Reports!RptCustJobDetails.Printer.ItemSizeWidth = 19440 ’13.5 inches, in Twips for Legal, minus Margins
End If
End Sub
My research has now let me to believe that there no easy way of doing this.
If anyone has any good ideas about how to resolve this please let me know.
Thank you in advance for your help.