A.D.TEJPAL
adtp at airtelbroadband.in
Fri Nov 9 23:17:59 CST 2007
You are most welcome Susan! Thanks for the generous compliment. Glad you could make a success of it. A.D.Tejpal ------------ ----- Original Message ----- From: Susan Harkins To: Access Developers discussion and problem solving Sent: Friday, November 09, 2007 20:26 Subject: Re: [AccessD] storing last item on the page A.D., you are a genius -- you are right, I had the code right, just executing it in reverse! 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.txtHeaderLast = col(Me.Page) End Sub Private Sub Report_Close() Set col = Nothing End Sub It's working perfectly now -- thank you A.D. I was going to rearrange things this morning, after sleeping on the problem last night, but your message helped a lot. I would've been working purely on speculation and you gave me a map. ;) Now, I don't know if anyone else agrees with me, but I think this is much simpler than the more common array solution. Susan H. > 2 - Page Footer is the appropriate place to grab a value from last > record of detail section and add it to the collection. You are wrongly > using Page Header for this purpose. > > 3 - You are using Page Footer to assign a value (from collection) to > txtHeaderLast. In view of the nature of forward time flow during report > execution, the effect of such assignment materializes only on the next > page. This defeats the very purpose of building a collection of last > values in forced first pass of formatting. The proper place for making > such an assignment is Page Header (preferably its print event, as by then, > building up of collection during prior formatting pass, is complete). > > Sample code in report's module, as given below, demonstrates collection > based solution. All the four controls (TxtHeaderFirst, TxtHeaderLast, > TxtFooterFirst, TxtFooterLast) are unbound. In the sample code, "Title" is > the name of control in detail section whose first and last values are > required to be displayed in page header as well as footer. You can > substitute the name of actual control in your report, suitably. > > A.D.Tejpal