Results 1 to 2 of 2

Thread: PageNumber and TotalPages by Group

  1. #1
    Join Date
    Mar 2005
    Posts
    2

    PageNumber and TotalPages by Group

    I have a report generated for all Customers that is grouped by Customer and seperated out before sending out. So I need the Page Numbering to be withing the Customer Group. So Customer A, Page 1 of 4, Customer B Page 1 of 6, Customer C Page 1 of 3. Is this possible ?
    Last edited by blowinoil; 03-07-2005 at 07:03 PM.

  2. #2
    Join Date
    Mar 2005
    Posts
    2
    Couldn't get Page X of Y, but could get Page X (reset on new group).

    Also got group fields in the header.

    You have to use an array in the Custom code to store the group information and page numbers

    Details


    Step 1) Add the Custom Code to store and Display the info. (also has a group list function - for the end of the report)


    Public Shared HeaderArray(3,1500) As String
    Public Shared BlankHeaderArray(3,1500) As String
    Public Shared Header1 As String
    Public Shared Header2 As String
    Public Shared Header3 As Integer
    Public Shared Header4 As Integer
    Public Shared PageNumber As Integer
    Public Shared ArrayNumber As Integer
    Public Shared ArrayNumberGet1 As Integer
    Public Shared ArrayNumberGet2 As Integer
    Public Shared GroupNumber As Integer
    Public Shared LastGroupId As Integer
    Public Shared CurrentGroupId1 As Integer
    Public Shared CurrentGroupId2 As Integer
    Public Shared CurrentGroupPageNum As Integer

    Public Shared Function ResetHeaderArray() As String
    LastGroupId = 0
    ArrayNumber = 0
    ArrayNumberGet1 = 0
    ArrayNumberGet2 = 0
    CurrentGroupId1 = 0
    CurrentGroupId2 = 0
    HeaderArray = BlankHeaderArray
    ResetHeaderArray= ""
    CurrentGroupPageNum = 0
    End Function


    Public Shared Function StoreHeaderInfo( head1 As String, head2 As String, head3 As Integer) As String
    If (HeaderArray(2,ArrayNumber) = head3 or head3 = 0 or head3 = LastGroupId) Then
    LastGroupId = HeaderArray(2,ArrayNumber)
    Else
    ArrayNumber = ArrayNumber + 1
    HeaderArray(0,ArrayNumber) = head1
    HeaderArray(1,ArrayNumber) = cstr(head2)
    HeaderArray(2,ArrayNumber) = cstr(head3)
    HeaderArray(3,ArrayNumber) = 0
    LastGroupId = HeaderArray(2,ArrayNumber)
    End If
    StoreHeaderInfo = ""
    End Function

    Public Shared Function GetHeader(ColumnNum as Integer, GroupId as Integer, MaxPageNum as Integer) As String
    If (GroupId <> CurrentGroupId1 and GroupId <> 0 and GroupId > CurrentGroupId1 and ColumnNum = 0) Then
    CurrentGroupId1 = GroupId
    ArrayNumberGet1 = ArrayNumberGet1 + 1
    End If
    GetHeader = HeaderArray(ColumnNum,ArrayNumberGet1)
    End Function

    Public Shared Function ListHeader(ColumnNum as Integer) As String
    dim i as integer
    dim outstring as string
    i = 1
    outstring = ""
    while (HeaderArray(ColumnNum,i) <> "" )
    outstring = outstring + HeaderArray(ColumnNum,i) + chr(13)+ chr(10)
    i = i + 1
    End While
    ListHeader = outstring
    End Function


    Public Shared Function SetPageNumber() As Integer
    If LastGroupId = Header3 Then
    GroupNumber = GroupNumber + 1
    Else
    LastGroupId = 0
    GroupNumber = 1
    End If
    SetPageNumber = GroupNumber
    End Function

    Public Shared Function GetPageNumber(GroupId as Integer) As String
    If (GroupId <> CurrentGroupId2 and GroupId <> 0) Then
    CurrentGroupId2 = GroupId
    ArrayNumberGet2 = ArrayNumberGet2 + 1
    CurrentGroupPageNum = 0
    End If
    CurrentGroupPageNum = CurrentGroupPageNum + 1
    GetPageNumber = "Page " + cstr(CurrentGroupPageNum)
    End Function



    Step 2) Add a following fields to the report body

    a) textbox at top of the report body above the table (created below)

    =Code.ResetHeaderArray()

    b) below this textbox create a table with the appropriate group you need

    c) create a textbox in the group header - that stores the group information at the start of the group

    =Code.StoreHeaderInfo( Fields!group_code.Value , Fields!group_description.Value , Fields!group_id.Value )

    d) add a field in the same row with the group ID (you make white, do not change the visibility)

    = Fields!group_id.Value

    e) Make note of the textbox number for the field above e.g 99



    Step 3) Add heading fields (for the group)

    Add 3 textboxs in the report heading area (not the table group header) with a values of

    =Code.GetHeader(0,ReportItems!textbox99.value, Globals!PageNumber)
    =Code.GetHeader(1,ReportItems!textbox99.value, Globals!PageNumber)
    =Code.GetHeader(2,ReportItems!textbox99.value, Globals!PageNumber)

    Note the 99 is textbox number from step 2e above

    The one with the 0 is also storing the page number for the group


    Step 4) Add the Page Number field in the Report Footer

    =Code.GetPageNumber(ReportItems!textbox99.value)

    Thats it

    You can also use the ListHeader function to report groups in the footer of the report

    =code.listheader(0)
    =code.listheader(1)
    =code.listheader(2)

    Also if you work out how to get the Page X of Y for the group please let me know at blowinoil@hotmail.com

    Good Luck

    Blowinoil
    Last edited by blowinoil; 04-19-2005 at 09:55 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •