dbTalk Databases Forums  

Print last page of a report

comp.databases.ms-access comp.databases.ms-access


Discuss Print last page of a report in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Phil
 
Posts: n/a

Default Print last page of a report - 11-13-2010 , 12:37 PM






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

Thanks

Phil

Reply With Quote
  #2  
Old   
Marshall Barton
 
Posts: n/a

Default Re: Print last page of a report - 11-13-2010 , 02:57 PM






Phil wrote:
Quote:
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

Reply With Quote
  #3  
Old   
Phil
 
Posts: n/a

Default Re: Print last page of a report - 11-13-2010 , 05:13 PM



On 13/11/2010 20:57:07, Marshall Barton wrote:
Quote:
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.

Phil

Reply With Quote
  #4  
Old   
Marshall Barton
 
Posts: n/a

Default Re: Print last page of a report - 11-13-2010 , 05:48 PM



Phil wrote:

Quote:
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

Reply With Quote
  #5  
Old   
Phil
 
Posts: n/a

Default Re: Print last page of a report - 11-13-2010 , 06:06 PM



On 13/11/2010 23:48:11, Marshall Barton wrote:
Quote:
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

Hi Marsh

Should have believed you in the first place ... Perfect (actually better than
perfect as it shows all the other footer totals as well.

Thanks everso

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.

Phil

Reply With Quote
  #6  
Old   
Marshall Barton
 
Posts: n/a

Default Re: Print last page of a report - 11-13-2010 , 06:56 PM



Phil wrote:

Quote:
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.

Honestly, I never tried to debug a report in Normal view.
Doesn't seem to make a lot of sense to debug something you
can't see, so I'll speculate that this behavior is by
design.

--
Marsh

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.