![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Many of my reports have summaries / totals on the last page. For end of year reports I only need these totals, not all the detailed stuff on earlier pages. Can anyone suggest a VBA routine to print only that last page. Using Access 2010 |
#3
| |||
| |||
|
|
Phil wrote: Many of my reports have summaries / totals on the last page. For end of year reports I only need these totals, not all the detailed stuff on earlier pages. Can anyone suggest a VBA routine to print only that last page. Using Access 2010 You can use check box control on the form that opens the report and have the report's Open event make all the other sections invisible. The code in the report's Open event procedure could then look like: If Forms!theform.thecheckbox <> False Then Me.Section(0).Visible = False Me.Section(1).Visible = False Me.Section(3).Visible = False Me.Section(4).Visible = False End If Or just use a second button to indicate how the report should be displayed. The summary button could pass an indicator to the report in the OpenReport method's OpenArgs argument with similar code in the report's open event. Personally, I usually prefer to create a separate report with a record source query that calculates all the totals. Then the form can use two buttons, one for each report. You can probably modify your existing report to eliminate the totals calculations and use the new totals report as a subreport in the report footer section so the calculations would not be duplicated both reports. -- Marsh |
#4
| |||
| |||
|
|
On 13/11/2010 20:57:07, Marshall Barton wrote: Phil wrote: Many of my reports have summaries / totals on the last page. For end of year reports I only need these totals, not all the detailed stuff on earlier pages. Can anyone suggest a VBA routine to print only that last page. Using Access 2010 You can use check box control on the form that opens the report and have the report's Open event make all the other sections invisible. The code in the report's Open event procedure could then look like: If Forms!theform.thecheckbox <> False Then Me.Section(0).Visible = False Me.Section(1).Visible = False Me.Section(3).Visible = False Me.Section(4).Visible = False End If Or just use a second button to indicate how the report should be displayed. The summary button could pass an indicator to the report in the OpenReport method's OpenArgs argument with similar code in the report's open event. Personally, I usually prefer to create a separate report with a record source query that calculates all the totals. Then the form can use two buttons, one for each report. You can probably modify your existing report to eliminate the totals calculations and use the new totals report as a subreport in the report footer section so the calculations would not be duplicated both reports. -- Marsh Thanks, Marsh I was hoping this might work Private Sub PageFooterSection_Print(Cancel As Integer, PrintCount As Integer) If IsLoaded("EndYear") Then ' End year being run If Forms!EndYear!PrintDaybook = False Then ' Not printed If Me.Page < Me.Pages Then SendKeys "{PGDN}", False ' do not wait for processing End If End If End If End Sub but for some reason the Sub doesn't run. Don't understand why (I have set a breakpoint on the first line) May have to resort to your method of separate reports, but the FE database is alreadt 23Mb in size and getting a handful to maintain. |
#5
| |||
| |||
|
|
Phil wrote: On 13/11/2010 20:57:07, Marshall Barton wrote: Phil wrote: Many of my reports have summaries / totals on the last page. For end of year reports I only need these totals, not all the detailed stuff on earlier pages. Can anyone suggest a VBA routine to print only that last page. Using Access 2010 You can use check box control on the form that opens the report and have the report's Open event make all the other sections invisible. The code in the report's Open event procedure could then look like: If Forms!theform.thecheckbox <> False Then Me.Section(0).Visible = False Me.Section(1).Visible = False Me.Section(3).Visible = False Me.Section(4).Visible = False End If Or just use a second button to indicate how the report should be displayed. The summary button could pass an indicator to the report in the OpenReport method's OpenArgs argument with similar code in the report's open event. Personally, I usually prefer to create a separate report with a record source query that calculates all the totals. Then the form can use two buttons, one for each report. You can probably modify your existing report to eliminate the totals calculations and use the new totals report as a subreport in the report footer section so the calculations would not be duplicated both reports. -- Marsh Thanks, Marsh I was hoping this might work Private Sub PageFooterSection_Print(Cancel As Integer, PrintCount As Integer) If IsLoaded("EndYear") Then ' End year being run If Forms!EndYear!PrintDaybook = False Then ' Not printed If Me.Page < Me.Pages Then SendKeys "{PGDN}", False ' do not wait for processing End If End If End If End Sub but for some reason the Sub doesn't run. Don't understand why (I have set a breakpoint on the first line) May have to resort to your method of separate reports, but the FE database is alreadt 23Mb in size and getting a handful to maintain. That's way too devious to work ;-) Seriously, PgDn isn't useful at that point in time AND SendKeys is too unreliable to be useful for much of anything, avoid it like the plague it is. Try using the Open event as I said earlier: If IsLoaded("EndYear") Then ' End year being run If Forms!EndYear!PrintDaybook = False Then ' Not printed Me.Section(0).Visible = False Me.Section(1).Visible = False Me.Section(3).Visible = False Me.Section(4).Visible = False End If End If Also check your IsLoaded function to make sure it does what you expect and that the form remains open while the report is open. -- Marsh |
#6
| |||
| |||
|
|
On 13/11/2010 23:48:11, Marshall Barton wrote: Phil wrote: On 13/11/2010 20:57:07, Marshall Barton wrote: Phil wrote: Many of my reports have summaries / totals on the last page. For end of year reports I only need these totals, not all the detailed stuff on earlier pages. Can anyone suggest a VBA routine to print only that last page. Using Access 2010 You can use check box control on the form that opens the report and have the report's Open event make all the other sections invisible. The code in the report's Open event procedure could then look like: If Forms!theform.thecheckbox <> False Then Me.Section(0).Visible = False Me.Section(1).Visible = False Me.Section(3).Visible = False Me.Section(4).Visible = False End If Or just use a second button to indicate how the report should be displayed. The summary button could pass an indicator to the report in the OpenReport method's OpenArgs argument with similar code in the report's open event. Personally, I usually prefer to create a separate report with a record source query that calculates all the totals. Then the form can use two buttons, one for each report. You can probably modify your existing report to eliminate the totals calculations and use the new totals report as a subreport in the report footer section so the calculations would not be duplicated both reports. [snip] Try using the Open event as I said earlier: If IsLoaded("EndYear") Then ' End year being run If Forms!EndYear!PrintDaybook = False Then ' Not printed Me.Section(0).Visible = False Me.Section(1).Visible = False Me.Section(3).Visible = False Me.Section(4).Visible = False End If End If Should have believed you in the first place ... Perfect (actually better than perfect as it shows all the other footer totals as well. Interestingly, while playing, I found that if I put a breakpoint at on any subroutine (OnOpen, OnFormat, OnPrint & OnClose), non of them stop if I am printing the report (opened acNormal), but all break as expected when the report is opened acPreview. Is that normal, or is it a bug. |
![]() |
| Thread Tools | |
| Display Modes | |
| |