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!

Page Numbering Problem when printing Multiple 1-page reports 1

Status
Not open for further replies.

sterlecki

Technical User
Oct 25, 2003
181
US
I have a one page report that when printed individually prints Page 1 of 1 just fine.

I use a multi-select list box to print several of these report at one time with this code.
Code:
For Each varItem In Me.lbo_PrintSelectWells.ItemsSelected
        strList = strList & ",'" & Me.lbo_PrintSelectWells.Column(0, varItem) & "'"
        Next varItem
        strList = Mid$(strList, 2)
        stLinkCriteria = "[API] IN (" & strList & ")"
        Debug.Print stLinkCriteria
        
    DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria
    

    End If

Problem is that the subsequent reports say Page 2 of #, Page 3 of # etc. I want them to all say Page 1 of 1 unless it actually becomes a 2 pager.

Putting
Code:
="Page " & [Page] & " of " & [Pages]
in a group footer didn't seem to work.



Any thoughts
 
Hello Dhookom!

I tried this but get a Run-Time error 9: Subscript out of Range:

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

'************ Code Start *************
' This code was originally written by James H Brooks.
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.
'
' Code Courtesy of
' James H Brooks
'


Dim GrpArrayPage(), GrpArrayPages()
Dim GrpNameCurrent As Variant, GrpNamePrevious As Variant
Dim GrpPage As Integer, GrpPages As Integer

Dim i As Integer
  If Me.Pages = 0 Then
    ReDim Preserve GrpArrayPage(Me.Page + 1)
    ReDim Preserve GrpArrayPages(Me.Page + 1)
    GrpNameCurrent = Me.API
    If GrpNameCurrent = GrpNamePrevious Then
        GrpArrayPage(Me.Page) = GrpArrayPage(Me.Page - 1) + 1
        GrpPages = GrpArrayPage(Me.Page)
            For i = Me.Page - ((GrpPages) - 1) To Me.Page
                GrpArrayPages(i) = GrpPages
            Next i
    Else
        GrpPage = 1
        GrpArrayPage(Me.Page) = GrpPage
        GrpArrayPages(Me.Page) = GrpPage
    End If
  Else
[Highlight]    Me!ctlGrpPages = "Group Page " & GrpArrayPage(Me.Page) & " of " & GrpArrayPages(Me.Page)[/Highlight]
  End If
  GrpNamePrevious = GrpNameCurrent
End Sub
'************ Code End *************

Debugger shows it hanging on the yellow highlight line.
I changed the Me!Salesperson to Me.API and placed an unbound text box in the footer named ctlGrpPages.

Not sure whats causing the error. Debugger Values as follows

me!ctlGrpPages = Null

GrpArrayPage(Me.Page) shows <subscript out of range>
me.Page = 1

Same results as above for GrpArrayPages(Me.Page)

I have also Grouped my report on API but I'm not sure that has any effect.
 
I have found it is necessary to add a text box in your page footer with a control source of:
=[Page] & " of " & [Pages]
This doesn't have to be visible.

Also, you didn't copy the code correctly. These lines should be in the General Declarations section of code, not in the PageFooterSection_Format:
Code:
Dim GrpArrayPage(), GrpArrayPages()
Dim GrpNameCurrent As Variant, GrpNamePrevious As Variant
Dim GrpPage As Integer, GrpPages As Integer

Duane
Hook'D on Access
MS Access MVP
 
If it's always a single page report, why not just put a fakey label "Page 1 of 1" and leave it at that?

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244. Basics at
 
dhookom

thanks for the extra set of eyes. That "Detail" totally escaped me on this Monday morning.

Star for you. It works perfect now.

GingerR While it's intended to be a one pager and I have a second report with similar intents I needed to plan for possibility that it might extend to a second page as I haven't been too successful in shrinking it to one page via the printer such as with Excel vs. Access.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top