I have a report with values in the detail section. I want to show each day value from dates in a text box in a footer section. I’m stumped as to how to create some kind of loop. (See attached)
Thanks for any response,
Allan Bach
![]() |
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 » Access report VBA
I moved this post to the Databases forum as it is more likely to get a resolution here. Access VBA is a somewhat special case so questions like this are best responded to in the Databases forum.
Can you explain a bit more about what you want? Which numbers do you want to display there? Are you trying to concatenate the contents of a field into a summary field?
I have various dates in the detail section of a report. I want to concatenate each day part of the date into a field in the footer section. For example, if a client has meetings on 7/4/2014, 7/6/2014, and 7/20/2014, I want the days (4, 6, 20) to appear in a text box. I can get the day part of the dates, but I’m puzzled about placing the values. I thought about using a recordset and loop – not certain if that is the correct approach.
You can use a custom vba function to prepare the string and then place the result into the report. The following page shows how this string could be constructed and included as part of the query
http://allenbrowne.com/func-concat.html
You could choose to just use the function and put this result into a text box without including it in the query. You might also want to modify the code so it uses the recordset on the report rather than recreating the query.
Be aware that you may need your concat code to ignore multiple hits for the same day (if that is what you want)
Create a label in the Group Footer — lDays in this example
Click on the Group Header, add an Event Procedure for On Format with this code (Access adds the Sub and End Sub lines:
Me!lDays.Caption = “”
Click on Detail, add an Event Procedure for On Format with this code:
Me!lDays.Caption = Me!lDays.Caption & ” ” & [Day] (where [Day] is your data field name or text box displaying it)
That’s all!
Each time the group header changes, the label is cleared.
Each time a new detail is prepared for display, the Day is appended to the label.
The label automatically displays as part of the Group Footer.
If you want to use a text field rather than a label, you can accumulate the days in a variable, then set the field = variable in the Group Footer On Format.
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