Here's one for ya

  • Thread starter Thread starter Bill
  • Start date Start date
B

Bill

In the segment of code below, I show one
of two different types of totals. One when
bolCntrOn is true and the other a simple
record count taken from a textbox in the
report header that is bound to =count(*).

In the case of bolCntrOn = True, the
default text in Me.lblTotals.Caption is
used.

So what's the problem?? When bolCntrOn
is False and the caption is set to record
count, it will not print. I verified its setting
with the Debug.Print, but it's as though
the control is still not visible.

Bill


Private Sub PageFooterSection_Format(Cancel As Integer, FormatCount As
Integer)

If Page() = Pages() Then

Me.lblTotals.Visible = True
If bolCntrOn = True Then
Me.tbAccumulator.Visible = True 'Display counter
Else
Me.lblTotals.Caption = "Total: " & Me.tbRecCount 'Display record
count
Debug.Print Me.lblTotals.Caption

End If
End If

End Sub
 
Bill, I'm not sure of what you are aiming to achieve, here.

If you have a text box in the Report Header bound to:
=Count(*)
presumably this is meant to show the number of records in the report. That
should be fine provided there are any. If there are no records, calculated
expressions tend to show #Error. Perhaps that's why you are hiding it?

If that's the intention, you could test the report's HasData property
instead to see if there are any records, e.g.:
If Me.HasData Then SomeControl.Visible = False
or bind the text box to this (don't change "Report"):
=IIf([Report].[HasData], Count("*"), Null)

I was also confused by the brackets after Page() and Pages(). If you are
referring to the page number a count of pages, these are properties of the
report (not collections), so you don't need th brackets. There is a Pages()
collection in another context, but I don't think that's what you mean. Try:
If Me.Page = Me.Pages Then

It would also be good to make sure the line:
Option Explicit
appears at the top of the report's module so it can help you pin down what's
going on.

Finally, in some reports, the values you are shown in the Page Footer
section may not be as you expect. You should be okay on the last page of the
report, but it's worth keeping in mind. Oh: if you repeat records (using the
events and runtime properties PrintSection, NextRecord, MoveLayout), you may
find that the Pages doesn't match anymore, e.g. you could end up with Access
telling you that you are on Page 11 of 8.
 
"If Me.Page = Me.Pages Then" is what I had intended.
For the life of me, I don't know what I was thinking
a few weeks back when that statement was coded as
you see in my original post.

The case of no records is handled appropriately
elsewhere in the reports code sheet.

All I'm really doing is changing what gets printed in
the PageFooter, depending on what has been displayed
in the DetailSection. With the current database, the
report can be anywhere between 1 to several pages,
depending on the filtered RecordSource.

I just want the appropriate totals printed in the footer
section of the last page. All other page footers only
have Now() on the left and "page of pages" on the
right. What I'm making visible is the label that
appears in the center of the page footer.

I verified, as you can see with the Debug.Print, that
the offending report should have shown: "Totals: 22",
as that particular report had 22 records.

All my general and class modules have Option Explicit,
as of yet that feature hasn't flushed out the culprit.

Bill




Allen Browne said:
Bill, I'm not sure of what you are aiming to achieve, here.

If you have a text box in the Report Header bound to:
=Count(*)
presumably this is meant to show the number of records in the report. That
should be fine provided there are any. If there are no records, calculated
expressions tend to show #Error. Perhaps that's why you are hiding it?

If that's the intention, you could test the report's HasData property
instead to see if there are any records, e.g.:
If Me.HasData Then SomeControl.Visible = False
or bind the text box to this (don't change "Report"):
=IIf([Report].[HasData], Count("*"), Null)

I was also confused by the brackets after Page() and Pages(). If you are
referring to the page number a count of pages, these are properties of the
report (not collections), so you don't need th brackets. There is a
Pages() collection in another context, but I don't think that's what you
mean. Try:
If Me.Page = Me.Pages Then

It would also be good to make sure the line:
Option Explicit
appears at the top of the report's module so it can help you pin down
what's going on.

Finally, in some reports, the values you are shown in the Page Footer
section may not be as you expect. You should be okay on the last page of
the report, but it's worth keeping in mind. Oh: if you repeat records
(using the events and runtime properties PrintSection, NextRecord,
MoveLayout), you may find that the Pages doesn't match anymore, e.g. you
could end up with Access telling you that you are on Page 11 of 8.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Bill said:
In the segment of code below, I show one
of two different types of totals. One when
bolCntrOn is true and the other a simple
record count taken from a textbox in the
report header that is bound to =count(*).

In the case of bolCntrOn = True, the
default text in Me.lblTotals.Caption is
used.

So what's the problem?? When bolCntrOn
is False and the caption is set to record
count, it will not print. I verified its setting
with the Debug.Print, but it's as though
the control is still not visible.

Bill


Private Sub PageFooterSection_Format(Cancel As Integer, FormatCount As
Integer)

If Page() = Pages() Then

Me.lblTotals.Visible = True
If bolCntrOn = True Then
Me.tbAccumulator.Visible = True 'Display counter
Else
Me.lblTotals.Caption = "Total: " & Me.tbRecCount 'Display
record count
Debug.Print Me.lblTotals.Caption

End If
End If

End Sub
 
Okay, Bill, it might be worth adding some Debug.Print statements to see
which branches are being taken, and so track down which path Access is
taking.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Bill said:
"If Me.Page = Me.Pages Then" is what I had intended.
For the life of me, I don't know what I was thinking
a few weeks back when that statement was coded as
you see in my original post.

The case of no records is handled appropriately
elsewhere in the reports code sheet.

All I'm really doing is changing what gets printed in
the PageFooter, depending on what has been displayed
in the DetailSection. With the current database, the
report can be anywhere between 1 to several pages,
depending on the filtered RecordSource.

I just want the appropriate totals printed in the footer
section of the last page. All other page footers only
have Now() on the left and "page of pages" on the
right. What I'm making visible is the label that
appears in the center of the page footer.

I verified, as you can see with the Debug.Print, that
the offending report should have shown: "Totals: 22",
as that particular report had 22 records.

All my general and class modules have Option Explicit,
as of yet that feature hasn't flushed out the culprit.

Bill

Allen Browne said:
Bill, I'm not sure of what you are aiming to achieve, here.

If you have a text box in the Report Header bound to:
=Count(*)
presumably this is meant to show the number of records in the report.
That should be fine provided there are any. If there are no records,
calculated expressions tend to show #Error. Perhaps that's why you are
hiding it?

If that's the intention, you could test the report's HasData property
instead to see if there are any records, e.g.:
If Me.HasData Then SomeControl.Visible = False
or bind the text box to this (don't change "Report"):
=IIf([Report].[HasData], Count("*"), Null)

I was also confused by the brackets after Page() and Pages(). If you are
referring to the page number a count of pages, these are properties of
the report (not collections), so you don't need th brackets. There is a
Pages() collection in another context, but I don't think that's what you
mean. Try:
If Me.Page = Me.Pages Then

It would also be good to make sure the line:
Option Explicit
appears at the top of the report's module so it can help you pin down
what's going on.

Finally, in some reports, the values you are shown in the Page Footer
section may not be as you expect. You should be okay on the last page of
the report, but it's worth keeping in mind. Oh: if you repeat records
(using the events and runtime properties PrintSection, NextRecord,
MoveLayout), you may find that the Pages doesn't match anymore, e.g. you
could end up with Access telling you that you are on Page 11 of 8.

Bill said:
In the segment of code below, I show one
of two different types of totals. One when
bolCntrOn is true and the other a simple
record count taken from a textbox in the
report header that is bound to =count(*).

In the case of bolCntrOn = True, the
default text in Me.lblTotals.Caption is
used.

So what's the problem?? When bolCntrOn
is False and the caption is set to record
count, it will not print. I verified its setting
with the Debug.Print, but it's as though
the control is still not visible.

Bill


Private Sub PageFooterSection_Format(Cancel As Integer, FormatCount As
Integer)

If Page() = Pages() Then

Me.lblTotals.Visible = True
If bolCntrOn = True Then
Me.tbAccumulator.Visible = True 'Display counter
Else
Me.lblTotals.Caption = "Total: " & Me.tbRecCount 'Display
record count
Debug.Print Me.lblTotals.Caption

End If
End If

End Sub
 
Allen, here's the current code segment:
==============================================
If Me.Page = Me.Pages Then
Debug.Print "Me.Page equals Me.Pages"
Me.lblTotals.Visible = True
Debug.Print Me.lblTotals.Visible
If bolCntrOn = True Then
Debug.Print "bolCntrOn = " & bolCntrOn
Me.tbAccumulator.Visible = True 'Display counter
Else
Debug.Print "bolCntrOn = (Else) " & bolCntrOn
Me.lblTotals.Caption = "Total: " & Me.tbRecCount 'Display record
count
Debug.Print Me.lblTotals.Caption

End If
End If

End Sub
==============================================
And, the Immediate Window
==============================================
Me.Page equals Me.Pages
True
bolCntrOn = (Else) False
Total: 22
==============================================

"Me.lblTotals.Caption" still does not print.

Bill


Allen Browne said:
Okay, Bill, it might be worth adding some Debug.Print statements to see
which branches are being taken, and so track down which path Access is
taking.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Bill said:
"If Me.Page = Me.Pages Then" is what I had intended.
For the life of me, I don't know what I was thinking
a few weeks back when that statement was coded as
you see in my original post.

The case of no records is handled appropriately
elsewhere in the reports code sheet.

All I'm really doing is changing what gets printed in
the PageFooter, depending on what has been displayed
in the DetailSection. With the current database, the
report can be anywhere between 1 to several pages,
depending on the filtered RecordSource.

I just want the appropriate totals printed in the footer
section of the last page. All other page footers only
have Now() on the left and "page of pages" on the
right. What I'm making visible is the label that
appears in the center of the page footer.

I verified, as you can see with the Debug.Print, that
the offending report should have shown: "Totals: 22",
as that particular report had 22 records.

All my general and class modules have Option Explicit,
as of yet that feature hasn't flushed out the culprit.

Bill

Allen Browne said:
Bill, I'm not sure of what you are aiming to achieve, here.

If you have a text box in the Report Header bound to:
=Count(*)
presumably this is meant to show the number of records in the report.
That should be fine provided there are any. If there are no records,
calculated expressions tend to show #Error. Perhaps that's why you are
hiding it?

If that's the intention, you could test the report's HasData property
instead to see if there are any records, e.g.:
If Me.HasData Then SomeControl.Visible = False
or bind the text box to this (don't change "Report"):
=IIf([Report].[HasData], Count("*"), Null)

I was also confused by the brackets after Page() and Pages(). If you are
referring to the page number a count of pages, these are properties of
the report (not collections), so you don't need th brackets. There is a
Pages() collection in another context, but I don't think that's what you
mean. Try:
If Me.Page = Me.Pages Then

It would also be good to make sure the line:
Option Explicit
appears at the top of the report's module so it can help you pin down
what's going on.

Finally, in some reports, the values you are shown in the Page Footer
section may not be as you expect. You should be okay on the last page of
the report, but it's worth keeping in mind. Oh: if you repeat records
(using the events and runtime properties PrintSection, NextRecord,
MoveLayout), you may find that the Pages doesn't match anymore, e.g. you
could end up with Access telling you that you are on Page 11 of 8.

In the segment of code below, I show one
of two different types of totals. One when
bolCntrOn is true and the other a simple
record count taken from a textbox in the
report header that is bound to =count(*).

In the case of bolCntrOn = True, the
default text in Me.lblTotals.Caption is
used.

So what's the problem?? When bolCntrOn
is False and the caption is set to record
count, it will not print. I verified its setting
with the Debug.Print, but it's as though
the control is still not visible.

Bill


Private Sub PageFooterSection_Format(Cancel As Integer, FormatCount As
Integer)

If Page() = Pages() Then

Me.lblTotals.Visible = True
If bolCntrOn = True Then
Me.tbAccumulator.Visible = True 'Display
counter
Else
Me.lblTotals.Caption = "Total: " & Me.tbRecCount 'Display
record count
Debug.Print Me.lblTotals.Caption

End If
End If

End Sub
 
A different RecordSet, same code:
========================================
Me.Page equals Me.Pages
True
bolCntrOn = (Else) False
Total: 157
========================================
Bill


Allen Browne said:
Okay, Bill, it might be worth adding some Debug.Print statements to see
which branches are being taken, and so track down which path Access is
taking.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Bill said:
"If Me.Page = Me.Pages Then" is what I had intended.
For the life of me, I don't know what I was thinking
a few weeks back when that statement was coded as
you see in my original post.

The case of no records is handled appropriately
elsewhere in the reports code sheet.

All I'm really doing is changing what gets printed in
the PageFooter, depending on what has been displayed
in the DetailSection. With the current database, the
report can be anywhere between 1 to several pages,
depending on the filtered RecordSource.

I just want the appropriate totals printed in the footer
section of the last page. All other page footers only
have Now() on the left and "page of pages" on the
right. What I'm making visible is the label that
appears in the center of the page footer.

I verified, as you can see with the Debug.Print, that
the offending report should have shown: "Totals: 22",
as that particular report had 22 records.

All my general and class modules have Option Explicit,
as of yet that feature hasn't flushed out the culprit.

Bill

Allen Browne said:
Bill, I'm not sure of what you are aiming to achieve, here.

If you have a text box in the Report Header bound to:
=Count(*)
presumably this is meant to show the number of records in the report.
That should be fine provided there are any. If there are no records,
calculated expressions tend to show #Error. Perhaps that's why you are
hiding it?

If that's the intention, you could test the report's HasData property
instead to see if there are any records, e.g.:
If Me.HasData Then SomeControl.Visible = False
or bind the text box to this (don't change "Report"):
=IIf([Report].[HasData], Count("*"), Null)

I was also confused by the brackets after Page() and Pages(). If you are
referring to the page number a count of pages, these are properties of
the report (not collections), so you don't need th brackets. There is a
Pages() collection in another context, but I don't think that's what you
mean. Try:
If Me.Page = Me.Pages Then

It would also be good to make sure the line:
Option Explicit
appears at the top of the report's module so it can help you pin down
what's going on.

Finally, in some reports, the values you are shown in the Page Footer
section may not be as you expect. You should be okay on the last page of
the report, but it's worth keeping in mind. Oh: if you repeat records
(using the events and runtime properties PrintSection, NextRecord,
MoveLayout), you may find that the Pages doesn't match anymore, e.g. you
could end up with Access telling you that you are on Page 11 of 8.

In the segment of code below, I show one
of two different types of totals. One when
bolCntrOn is true and the other a simple
record count taken from a textbox in the
report header that is bound to =count(*).

In the case of bolCntrOn = True, the
default text in Me.lblTotals.Caption is
used.

So what's the problem?? When bolCntrOn
is False and the caption is set to record
count, it will not print. I verified its setting
with the Debug.Print, but it's as though
the control is still not visible.

Bill


Private Sub PageFooterSection_Format(Cancel As Integer, FormatCount As
Integer)

If Page() = Pages() Then

Me.lblTotals.Visible = True
If bolCntrOn = True Then
Me.tbAccumulator.Visible = True 'Display
counter
Else
Me.lblTotals.Caption = "Total: " & Me.tbRecCount 'Display
record count
Debug.Print Me.lblTotals.Caption

End If
End If

End Sub
 
"Grasping for straws" now. I inserted a Msgbox
right after setting the label caption:

MsgBox "Me.lblTotals = " & Me.lblTotals.Caption & _
" Visible = " & Me.lblTotals.Visible

Sure enough:

"Totals: 22 Visible = True"

But still doesn't print footer.

What blows my mind is that is when alternate
path is taken to show Me.tbAccumulator the
footer prints as expected.

I'm "dead in the water" at this point.

Bill



Allen Browne said:
Okay, Bill, it might be worth adding some Debug.Print statements to see
which branches are being taken, and so track down which path Access is
taking.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Bill said:
"If Me.Page = Me.Pages Then" is what I had intended.
For the life of me, I don't know what I was thinking
a few weeks back when that statement was coded as
you see in my original post.

The case of no records is handled appropriately
elsewhere in the reports code sheet.

All I'm really doing is changing what gets printed in
the PageFooter, depending on what has been displayed
in the DetailSection. With the current database, the
report can be anywhere between 1 to several pages,
depending on the filtered RecordSource.

I just want the appropriate totals printed in the footer
section of the last page. All other page footers only
have Now() on the left and "page of pages" on the
right. What I'm making visible is the label that
appears in the center of the page footer.

I verified, as you can see with the Debug.Print, that
the offending report should have shown: "Totals: 22",
as that particular report had 22 records.

All my general and class modules have Option Explicit,
as of yet that feature hasn't flushed out the culprit.

Bill

Allen Browne said:
Bill, I'm not sure of what you are aiming to achieve, here.

If you have a text box in the Report Header bound to:
=Count(*)
presumably this is meant to show the number of records in the report.
That should be fine provided there are any. If there are no records,
calculated expressions tend to show #Error. Perhaps that's why you are
hiding it?

If that's the intention, you could test the report's HasData property
instead to see if there are any records, e.g.:
If Me.HasData Then SomeControl.Visible = False
or bind the text box to this (don't change "Report"):
=IIf([Report].[HasData], Count("*"), Null)

I was also confused by the brackets after Page() and Pages(). If you are
referring to the page number a count of pages, these are properties of
the report (not collections), so you don't need th brackets. There is a
Pages() collection in another context, but I don't think that's what you
mean. Try:
If Me.Page = Me.Pages Then

It would also be good to make sure the line:
Option Explicit
appears at the top of the report's module so it can help you pin down
what's going on.

Finally, in some reports, the values you are shown in the Page Footer
section may not be as you expect. You should be okay on the last page of
the report, but it's worth keeping in mind. Oh: if you repeat records
(using the events and runtime properties PrintSection, NextRecord,
MoveLayout), you may find that the Pages doesn't match anymore, e.g. you
could end up with Access telling you that you are on Page 11 of 8.

In the segment of code below, I show one
of two different types of totals. One when
bolCntrOn is true and the other a simple
record count taken from a textbox in the
report header that is bound to =count(*).

In the case of bolCntrOn = True, the
default text in Me.lblTotals.Caption is
used.

So what's the problem?? When bolCntrOn
is False and the caption is set to record
count, it will not print. I verified its setting
with the Debug.Print, but it's as though
the control is still not visible.

Bill


Private Sub PageFooterSection_Format(Cancel As Integer, FormatCount As
Integer)

If Page() = Pages() Then

Me.lblTotals.Visible = True
If bolCntrOn = True Then
Me.tbAccumulator.Visible = True 'Display
counter
Else
Me.lblTotals.Caption = "Total: " & Me.tbRecCount 'Display
record count
Debug.Print Me.lblTotals.Caption

End If
End If

End Sub
 
If lblTotals is an attached label, and the control it is attached to has its
Visible property set to No, then the label won't show.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Bill said:
Allen, here's the current code segment:
==============================================
If Me.Page = Me.Pages Then
Debug.Print "Me.Page equals Me.Pages"
Me.lblTotals.Visible = True
Debug.Print Me.lblTotals.Visible
If bolCntrOn = True Then
Debug.Print "bolCntrOn = " & bolCntrOn
Me.tbAccumulator.Visible = True 'Display counter
Else
Debug.Print "bolCntrOn = (Else) " & bolCntrOn
Me.lblTotals.Caption = "Total: " & Me.tbRecCount 'Display record
count
Debug.Print Me.lblTotals.Caption

End If
End If

End Sub
==============================================
And, the Immediate Window
==============================================
Me.Page equals Me.Pages
True
bolCntrOn = (Else) False
Total: 22
==============================================

"Me.lblTotals.Caption" still does not print.

Bill


Allen Browne said:
Okay, Bill, it might be worth adding some Debug.Print statements to see
which branches are being taken, and so track down which path Access is
taking.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Bill said:
"If Me.Page = Me.Pages Then" is what I had intended.
For the life of me, I don't know what I was thinking
a few weeks back when that statement was coded as
you see in my original post.

The case of no records is handled appropriately
elsewhere in the reports code sheet.

All I'm really doing is changing what gets printed in
the PageFooter, depending on what has been displayed
in the DetailSection. With the current database, the
report can be anywhere between 1 to several pages,
depending on the filtered RecordSource.

I just want the appropriate totals printed in the footer
section of the last page. All other page footers only
have Now() on the left and "page of pages" on the
right. What I'm making visible is the label that
appears in the center of the page footer.

I verified, as you can see with the Debug.Print, that
the offending report should have shown: "Totals: 22",
as that particular report had 22 records.

All my general and class modules have Option Explicit,
as of yet that feature hasn't flushed out the culprit.

Bill

Bill, I'm not sure of what you are aiming to achieve, here.

If you have a text box in the Report Header bound to:
=Count(*)
presumably this is meant to show the number of records in the report.
That should be fine provided there are any. If there are no records,
calculated expressions tend to show #Error. Perhaps that's why you are
hiding it?

If that's the intention, you could test the report's HasData property
instead to see if there are any records, e.g.:
If Me.HasData Then SomeControl.Visible = False
or bind the text box to this (don't change "Report"):
=IIf([Report].[HasData], Count("*"), Null)

I was also confused by the brackets after Page() and Pages(). If you
are referring to the page number a count of pages, these are properties
of the report (not collections), so you don't need th brackets. There
is a Pages() collection in another context, but I don't think that's
what you mean. Try:
If Me.Page = Me.Pages Then

It would also be good to make sure the line:
Option Explicit
appears at the top of the report's module so it can help you pin down
what's going on.

Finally, in some reports, the values you are shown in the Page Footer
section may not be as you expect. You should be okay on the last page
of the report, but it's worth keeping in mind. Oh: if you repeat
records (using the events and runtime properties PrintSection,
NextRecord, MoveLayout), you may find that the Pages doesn't match
anymore, e.g. you could end up with Access telling you that you are on
Page 11 of 8.

In the segment of code below, I show one
of two different types of totals. One when
bolCntrOn is true and the other a simple
record count taken from a textbox in the
report header that is bound to =count(*).

In the case of bolCntrOn = True, the
default text in Me.lblTotals.Caption is
used.

So what's the problem?? When bolCntrOn
is False and the caption is set to record
count, it will not print. I verified its setting
with the Debug.Print, but it's as though
the control is still not visible.

Bill


Private Sub PageFooterSection_Format(Cancel As Integer, FormatCount As
Integer)

If Page() = Pages() Then

Me.lblTotals.Visible = True
If bolCntrOn = True Then
Me.tbAccumulator.Visible = True 'Display
counter
Else
Me.lblTotals.Caption = "Total: " & Me.tbRecCount 'Display
record count
Debug.Print Me.lblTotals.Caption

End If
End If

End Sub
 
BINGO!!!!!!!!!

The label was in indeed attached to
a text box that was not visible.

Thanks so much Allen for hanging in there
with this one...........what a lesson learned!

Bill


Allen Browne said:
If lblTotals is an attached label, and the control it is attached to has
its Visible property set to No, then the label won't show.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Bill said:
Allen, here's the current code segment:
==============================================
If Me.Page = Me.Pages Then
Debug.Print "Me.Page equals Me.Pages"
Me.lblTotals.Visible = True
Debug.Print Me.lblTotals.Visible
If bolCntrOn = True Then
Debug.Print "bolCntrOn = " & bolCntrOn
Me.tbAccumulator.Visible = True 'Display counter
Else
Debug.Print "bolCntrOn = (Else) " & bolCntrOn
Me.lblTotals.Caption = "Total: " & Me.tbRecCount 'Display
record count
Debug.Print Me.lblTotals.Caption

End If
End If

End Sub
==============================================
And, the Immediate Window
==============================================
Me.Page equals Me.Pages
True
bolCntrOn = (Else) False
Total: 22
==============================================

"Me.lblTotals.Caption" still does not print.

Bill


Allen Browne said:
Okay, Bill, it might be worth adding some Debug.Print statements to see
which branches are being taken, and so track down which path Access is
taking.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

"If Me.Page = Me.Pages Then" is what I had intended.
For the life of me, I don't know what I was thinking
a few weeks back when that statement was coded as
you see in my original post.

The case of no records is handled appropriately
elsewhere in the reports code sheet.

All I'm really doing is changing what gets printed in
the PageFooter, depending on what has been displayed
in the DetailSection. With the current database, the
report can be anywhere between 1 to several pages,
depending on the filtered RecordSource.

I just want the appropriate totals printed in the footer
section of the last page. All other page footers only
have Now() on the left and "page of pages" on the
right. What I'm making visible is the label that
appears in the center of the page footer.

I verified, as you can see with the Debug.Print, that
the offending report should have shown: "Totals: 22",
as that particular report had 22 records.

All my general and class modules have Option Explicit,
as of yet that feature hasn't flushed out the culprit.

Bill

Bill, I'm not sure of what you are aiming to achieve, here.

If you have a text box in the Report Header bound to:
=Count(*)
presumably this is meant to show the number of records in the report.
That should be fine provided there are any. If there are no records,
calculated expressions tend to show #Error. Perhaps that's why you are
hiding it?

If that's the intention, you could test the report's HasData property
instead to see if there are any records, e.g.:
If Me.HasData Then SomeControl.Visible = False
or bind the text box to this (don't change "Report"):
=IIf([Report].[HasData], Count("*"), Null)

I was also confused by the brackets after Page() and Pages(). If you
are referring to the page number a count of pages, these are
properties of the report (not collections), so you don't need th
brackets. There is a Pages() collection in another context, but I
don't think that's what you mean. Try:
If Me.Page = Me.Pages Then

It would also be good to make sure the line:
Option Explicit
appears at the top of the report's module so it can help you pin down
what's going on.

Finally, in some reports, the values you are shown in the Page Footer
section may not be as you expect. You should be okay on the last page
of the report, but it's worth keeping in mind. Oh: if you repeat
records (using the events and runtime properties PrintSection,
NextRecord, MoveLayout), you may find that the Pages doesn't match
anymore, e.g. you could end up with Access telling you that you are on
Page 11 of 8.

In the segment of code below, I show one
of two different types of totals. One when
bolCntrOn is true and the other a simple
record count taken from a textbox in the
report header that is bound to =count(*).

In the case of bolCntrOn = True, the
default text in Me.lblTotals.Caption is
used.

So what's the problem?? When bolCntrOn
is False and the caption is set to record
count, it will not print. I verified its setting
with the Debug.Print, but it's as though
the control is still not visible.

Bill


Private Sub PageFooterSection_Format(Cancel As Integer, FormatCount
As Integer)

If Page() = Pages() Then

Me.lblTotals.Visible = True
If bolCntrOn = True Then
Me.tbAccumulator.Visible = True 'Display
counter
Else
Me.lblTotals.Caption = "Total: " & Me.tbRecCount 'Display
record count
Debug.Print Me.lblTotals.Caption

End If
End If

End Sub
 
Back
Top