[AccessD] storing last item on the page

A.D.TEJPAL adtp at airtelbroadband.in
Wed Nov 7 00:15:41 CST 2007


Susan,

    For displaying the first and last items of report's detail section in its page header as well as footer, you have used four unbound text boxes as follows:

    (a) Page Header section:  TxtHeaderFirst and TxtHeaderLast
    (b) Page Footer section:  TxtFooterFirst and TxtFooterLast

    Assignment of values to TxtHeaderLast, located in page header section involves backward reference and therefore requires pre-building of array based upon first pass of formatting. For ensuring a complete prior cycle of formatting, you have correctly placed a calculated textbox having [Pages] as a component of its expression.

    Sample code in report's module, as given below, should get you the desired results. Title is the name of control in detail section, whose first & last values are required to be displayed in page header & footer.

Best wishes,
A.D.Tejpal
------------

Sample code in report's module
'=================================
' Declarations section
' Report level global array variable
Private ArLastVal() As String
'--------------------------------------------------

Private Sub PageFooterSection_Format(Cancel _
                        As Integer, FormatCount As Integer)
    Me.TxtFooterLast = Me.Title
    
    If Me.Pages = 0 Then
        ArLastVal([Page]) = Me.Title
        ReDim Preserve ArLastVal([Page] + 1)
    End If
End Sub
'--------------------------------------------------

Private Sub PageHeaderSection_Format(Cancel _
                        As Integer, FormatCount As Integer)
    Me.TxtHeaderFirst = Me.Title
    Me.TxtFooterFirst = Me.Title
    Me.TxtHeaderLast = ArLastVal([Page])
End Sub
'--------------------------------------------------

Private Sub Report_Open(Cancel As Integer)
    ReDim Preserve ArLastVal(1)
End Sub
'=================================

  ----- Original Message ----- 
  From: Susan Harkins 
  To: AccessD at databaseadvisors.com 
  Sent: Wednesday, November 07, 2007 01:21
  Subject: [AccessD] storing last item on the page


  I have four unbound text controls -- two in the header and two in the 
  footer -- to display the first and last items on each page.

  I've got three of them working as follows:

  I use the control's Control Source property to display the first item in the 
  header and the last item in the footer. I use the following to update the 
  footer's first item.

  Private Sub PageHeaderSection_Format(Cancel As Integer, FormatCount As 
  Integer)
    'Store first item on page for footer.
    Dim strFirst As String
    strFirst = Me.txtHeaderFirst
    Me.txtFooterFirst = strFirst
  End Sub

  I tried the following to update the header's last item, but it doesn't work:

  Private Sub PageFooterSection_Format(Cancel As Integer, FormatCount As 
  Integer)
    'Return last item on each page for header.
    Dim strLast As String
    strLast = Me.txtFooterLast
    Me.txtHeaderLast = strLast
  End Sub

  The first page displays nothing and all subsequent pages display the last 
  item from the previous page, not the current page.

  How do I grab the last item on the current page?

  Susan H. 


More information about the AccessD mailing list