[AccessD] report control not displaying right value

Susan Harkins ssharkins at gmail.com
Tue Nov 6 19:29:17 CST 2007


The following code is a simple solution, I thought, to displaying the last 
item on a page in the page header section. I've dropped in a few Debug 
statements to verify that the collection is storing and retrieving the right 
items, but the control always displays the first item on the page. I'm 
clueless -- I have no idea what's happening here.

Basically, during the first pass (I'm using the report Pages property to 
force a second formatting run), I'm storing the last item on each page --  
the value of txtFooterLast -- in a Collection object. That part works fine. 
Then, the report retrieves those values using the page number as the index 
value. The Debug statements verify that the right values are in the 
collection, however, txtHeaderLast doesn't display the results of 
col(Me.Page) -- it displays the first value on the page, not the value 
retrieved from the Collection. I just don't have any explanation.

Option Compare Database
Option Explicit
Dim col As New Collection


Private Sub PageFooterSection_Format(Cancel As Integer, FormatCount As 
Integer)
  Debug.Print Me.Page
  Debug.Print col(Me.Page)
  Me.txtHeaderLast = col(Me.Page)
  Debug.Print Me.txtHeaderLast.Value
End Sub

Private Sub PageHeaderSection_Format(Cancel As Integer, FormatCount As 
Integer)
  Me.txtFooterFirst = Me.txtHeaderFirst
  Me.txtHeaderLast = Me.txtFooterLast
  If Me.Pages = 0 Then
    col.Add Me.txtFooterLast, CStr(Me.Page)
  End If
End Sub

Private Sub Report_Close()
  Set col = Nothing
End Sub 




More information about the AccessD mailing list