I would like to get some ideas on how I could print first and last record on each page in the Page Section — Sort of like telephone book.
Can anyone suggest an easy solution? grin.
TIA
![]() |
Patch reliability is unclear. Unless you have an immediate, pressing need to install a specific patch, don't do it. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Printing first and last record on each page (Access 2K/SR1)
Check This Thread.
Thanks for finding this thread! I couldn’t find it – maybe bad search criteria.
I had tried that code from the Solutions database as well but exact same thing that happened to John happened to me…When I entered all that code…nothing happened. I run Access 2000 just like John. From Charlotte, it sounds like I need to modify my code using slightly different code. I’ll try that and get back to you if I don’t get it to work.
Thanks.
Well, cutting and pasting didn’t work. I’m pasting my codes and see if anyone could help.
(Name of Report is “Report1” because I made a copy and I will replace it as soon as I get the darned code working)
Option Compare Database ‘Use database order for sring comparisons.
Option Explicit
‘ Array for last record on each page and last record in recordset.
Dim gLast() As String
‘ Flag for number of passes through report.
Dim gLastPage As Integer
Private Sub PageHeaderSection_Format(Cancel As Integer, FormatCount As Integer)
‘ During second pass, fill in FirstEntry
‘ and LastEntry text boxes.
If gLastPage = True Then
Reports!Report1!FirstEntry = Reports!Report1!Name
Reports!Report1!LastEntry = gLast(Reports!Report1.Page)
End If
End Sub
Private Sub PageFooterSection_Format(Cancel As Integer, FormatCount As Integer)
‘ During first pass, increase size of array
‘ and enter last record on page into array.
If Not gLastPage Then
ReDim Preserve gLast(Reports!Report1.Page + 1)
gLast(Reports!Report1.Page) = Reports!Report1!Name
End If
End Sub
Private Sub ReportFooter_Format(Cancel As Integer, FormatCount As Integer)
Dim dbs As DAO.Database
Dim rst As Recordset
‘ Set flag after first pass has been completed.
gLastPage = True
‘Open recordset for report.
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset(“tblParticipant”)
‘ Move to last record in recordset.
rst.MoveLast
‘ Enter last record into array.
ReDim Preserve gLast(Reports!Report1.Page + 1)
gLast(Reports!Report1.Page) = rst!Name
End Sub
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.
Notifications