Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

total number of pages problem

Status
Not open for further replies.

Joallyn

Technical User
Jul 26, 2002
44
US
Hi all,

I've put the following code into the page footer section in order to keep the "Submitted By" text on the bottom of the last page only.

However, the only value "me.pages" ever has is 0, so it doesn't work. Can anyone point out where this went awry?


thanks!

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

If Me.Page = Me.Pages Then
Me.lineSubmittedBy.Visible = True
Else
Me.lineSubmittedBy.Visible = False
End If

End Sub
 
If you want to print the submitted by text on the last page only, you should put it in the report footer not in the page footer. If you don't see the report footer section, then right click on the report and select report Header/Footer.
Also, if you specifically want to use the page footer section try putting your code in the report's on page event instead of the PageFooterSection_Format event.
 
Are you just trying to print this report or are you previewing it also? You code should work if you are previewing the report first and move to the last page. The problem comes when you just try printing it. In that case you would want to move your code to the On Print Event for the Page Footer. That should do what you want.

Paul
 
Hi natatbh and Paul, thanks for responding.

I want the text to come at the bottom of the page, not after the last record; that's why I'm using the page footer section.

My main concern is that "me.pages" is always 0--it doesn't increment, no matter how many pages long the report is.

I've tried moving it around to different sections (report footer, on page, etc.) but it doesn't seem to make a difference.

I haven't tried printing the report yet...I've just previewed it.

thanks for the suggestions!

J
 
How are you determining Me.Pages is always staying at zero? I used the same code you have and it worked fine.

Paul
 
I added a breakpoint in the code. When the report opens the code pops up, and if I place the cursor over the variable me.pages it always reads "Me.pages = 0". Me.Page, on the other, increments nicely as the program steps through to the next page.

Aaargh!

J
 
Try this instead. Take out the breakpoint and run this code instead of what you have. Then when you open the report to preview, click on the record selector at the bottom of the page to take you to the last page in the report. See what you get for a message from your code.

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

If Me.Page = Me.Pages Then
Msgbox "There are " & Me.Pages & " in this report"
Else
Msgbox "I am currently on page " & Me.Page
End If

End Sub



Paul
 
I get a messagebox that announces "I am currently on page 2", but (unfortunately) no sign of the other messagebox.

In another post ( about first/last page numbers, I found what may be a clue:

"Until access has finished formatting the report for the first pass, the value of the Pages property will be 0"

Maybe it doesn't register, for some reason, that access has formatted the report.

How strange.

J
 
Ok, got it. The answer was in another thread705-64857: "to refer to the Pages property in a macro or Visual Basic, the form or report must include a text box whose ControlSource property is set to an expression that uses Pages."

So, I inserted a text box in the footer and set its control to =Pages.

All works well now, though my head hurts.

thanks for your help!

J
 
Sorry. I didn't have a clue you had to sort of initialize the Pages property before you could reference it. Thanks for the explanation and I'm glad you got it straightened out.

Paul
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top