A.D.TEJPAL
adtp at airtelbroadband.in
Sat Nov 10 07:13:51 CST 2007
In your code, second statement in page footer's format event is also redundant. The real assignment for txtHeaderLast is taking place in page header's print event. First two lines of existing code block can be removed. The only portion required in page footer's format event is the block of three lines meant to build up the collection. In page header's print event, while retrieving information from collection object, you have used number argument, which returns values as per index position in collection. This method does not take advantage of key strings that you have embedded (via CStr(Me.Page) as the second argument) while adding to the collection. Though in the present case, your results are not affected (being a simple situation), it is considered preferable in the interest of greater reliability to retrieve values using key (where available) instead of number index (specially if the collection is likely to get disturbed for some reason). Second statement in page header's print event would then become: Me.txtHeaderLast = col(CStr(Me.Page)) On the other hand, if you wish to continue using number index, it is not necessary to provide the second argument (for key string) in collection's Add method. The existing statement in page footer's format event would then become: col.Add Me.txtFooterLast.Value A.D.Tejpal ------------ ----- Original Message ----- From: Susan Harkins To: Access Developers discussion and problem solving Sent: Friday, November 09, 2007 21:06 Subject: Re: [AccessD] storing last item on the page Small correction to the previous code I posted -- I had to move the Me.txtFooterFirst statement back to the PageHeaderSection event. Susan H. Private Sub PageFooterSection_Format(Cancel As Integer, FormatCount As Integer) 'Me.txtFooterFirst = Me.txtHeaderFirst Me.txtHeaderLast = Me.txtFooterLast If Me.Pages = 0 Then col.Add Me.txtFooterLast.Value, CStr(Me.Page) End If End Sub Private Sub PageHeaderSection_Print(Cancel As Integer, PrintCount As Integer) Me.txtFooterFirst = Me.txtHeaderFirst Me.txtHeaderLast = col(Me.Page) End Sub Private Sub Report_Close() Set col = Nothing End Sub