By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,191 Members | 1,256 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,191 IT Pros & Developers. It's quick & easy.

Page Numbering Function

P: 32
I am trying to sequentially place page numbers across multiple reports.
Basically what I am trying to do is on the first report, which has 3 pages, the first page is page one...after cycling through the pages and then closing the report, the next report opens and the page number starts at 4.

I found an example of this, but when I try and incorporate it, it counts each line on the page as a page so instead of saying Page 1, it says Page 25 (the number of lines on the page is 24). I cannot figure it out.

Expand|Select|Wrap|Line Numbers
  1. (pagenumberfunctions)
  2.  
  3. Option Compare Database
  4.  
  5. Dim PageNumber As Integer
  6. Sub initPageNums()
  7.  PageNumber = 0
  8. End Sub
  9. Function GetPageNumbers() As Integer
  10.  PageNumber = PageNumber + 1
  11.  GetPageNumbers = PageNumber
  12. End Function
  13.  
That is my code in a module called pagenumberfunctions.

On the first report, on open, I call initPageNums as an event.
I then have an unbound text box in the page footer that has a control source of
=GetPageNumbers()

But like I said it displays 25 instead of 1, 25 being the number of lines on the page + 1. Why would it count each line as a seperate page?
Mar 20 '08 #1
Share this Question
Share on Google+
4 Replies


FishVal
Expert 2.5K+
P: 2,653
Hi, there.

I guess it calls the function each time it formats a record.
Would it be more reliable if your VBA function will return the first page number only and then in report control it will be added to current page number?

Regards,
Fish
Mar 20 '08 #2

ADezii
Expert 5K+
P: 8,638
I am trying to sequentially place page numbers across multiple reports.
Basically what I am trying to do is on the first report, which has 3 pages, the first page is page one...after cycling through the pages and then closing the report, the next report opens and the page number starts at 4.

I found an example of this, but when I try and incorporate it, it counts each line on the page as a page so instead of saying Page 1, it says Page 25 (the number of lines on the page is 24). I cannot figure it out.

Expand|Select|Wrap|Line Numbers
  1. (pagenumberfunctions)
  2.  
  3. Option Compare Database
  4.  
  5. Dim PageNumber As Integer
  6. Sub initPageNums()
  7.  PageNumber = 0
  8. End Sub
  9. Function GetPageNumbers() As Integer
  10.  PageNumber = PageNumber + 1
  11.  GetPageNumbers = PageNumber
  12. End Function
  13.  
That is my code in a module called pagenumberfunctions.

On the first report, on open, I call initPageNums as an event.
I then have an unbound text box in the page footer that has a control source of
=GetPageNumbers()

But like I said it displays 25 instead of 1, 25 being the number of lines on the page + 1. Why would it count each line as a seperate page?
  1. In Standard Code Module:
    Expand|Select|Wrap|Line Numbers
    1. Public lngPageNumber As Long
  2. Create a Text Box in all Page Footers in all Reports named txtPageNum.
  3. Initialize Public Variable in the Open() Event of the "1st" Form only:
    Expand|Select|Wrap|Line Numbers
    1. lngPageNum = 0
  4. Place the following code in the Format() Event of all Report Page Footers:
    Expand|Select|Wrap|Line Numbers
    1. Private Sub PageFooterSection_Format(Cancel As Integer, FormatCount As Integer)
    2.   lngPageNumber = lngPageNumber + 1
    3.   Me![txtPageNum] = "Page Number: " & lngPageNumber
    4. End Sub
Mar 20 '08 #3

P: 32
  1. In Standard Code Module:
    Expand|Select|Wrap|Line Numbers
    1. Public lngPageNumber As Long
  2. Create a Text Box in all Page Footers in all Reports named txtPageNum.
  3. Initialize Public Variable in the Open() Event of the "1st" Form only:
    Expand|Select|Wrap|Line Numbers
    1. lngPageNum = 0
  4. Place the following code in the Format() Event of all Report Page Footers:
    Expand|Select|Wrap|Line Numbers
    1. Private Sub PageFooterSection_Format(Cancel As Integer, FormatCount As Integer)
    2.   lngPageNumber = lngPageNumber + 1
    3.   Me![txtPageNum] = "Page Number: " & lngPageNumber
    4. End Sub

Thanks! I'll give this a try. Was planning on scrapping the original thought and trying to figure out a better way of doing it.. Appreciate it much!


edit: You are FABULOUS!!! That works, thanks
Mar 20 '08 #4

ADezii
Expert 5K+
P: 8,638
Thanks! I'll give this a try. Was planning on scrapping the original thought and trying to figure out a better way of doing it.. Appreciate it much!


edit: You are FABULOUS!!! That works, thanks
You are quite welcome.
Mar 20 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.