473,395 Members | 2,253 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Conditional Report Group Footer/Header using VBA

I currently have a Form with Option buttons (to give you the option of
sorting by name, or by Field, etc), these are referenced in a module
which then formats the report contingent on the option chosen (i.e.
the title changes to say "Sorted by Name" or "Sorted by Field"). For
one of the options, "Sort by Field" I would not only like to have them
sorted by Field alphabetically, but I would like to Group them and
have a Group Header and Footer and have each Field on a separate page.
I can of course do this if I specifically have a report setup with
the Grouping and the Footer and Header with the page break, but I was
wondering if there was a way to do this on the fly using VBA.

Thanks in advance for any advice.
Nov 12 '05 #1
1 12380
Shiz wrote:
I currently have a Form with Option buttons (to give you the option of
sorting by name, or by Field, etc), these are referenced in a module
which then formats the report contingent on the option chosen (i.e.
the title changes to say "Sorted by Name" or "Sorted by Field"). For
one of the options, "Sort by Field" I would not only like to have them
sorted by Field alphabetically, but I would like to Group them and
have a Group Header and Footer and have each Field on a separate page.
I can of course do this if I specifically have a report setup with
the Grouping and the Footer and Header with the page break, but I was
wondering if there was a way to do this on the fly using VBA.


You can use the report's Open event procedure to change the
properties of the header/footer sections and the GroupLevel
objects.

Start with the report that has the sorting and grouping set
up for one of the fields along with its associated header
and footer sections (with the header's ForceNewPage set to
Before Section). Then use code in the report's open event
to interrogate the form and set the properties as specified.
Here's some air code as an example:

Dim strFieldName As String
If Forms!theform.chkByName = True Then
Me.thelabel.Caption = "Sorted by Name"
Me.Section(5).Visible = False 'No header/footer
Me.Section(6).Visible = False
Me.GroupLevel(0).ControlSource = "=[namefield]"
Else
strFieldName = Forms!theform.fieldnamecombo
Me.thelabel.Caption = "Sort by Field " & strFieldName
Me.GroupLevel(0).ControlSource = strFieldName
End If

--
Marsh
Nov 12 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: SueB | last post by:
Greetings. I have a report based on the following query (hang in there ... it's quite long): SELECT Year(.) AS Yr, tblEvents.eventID, tblEvents.eventname, tblEvents.eventhost,...
7
by: Darin | last post by:
I have a report that sub-totals on a group, then grand-totals at the report footer. If there's only one group, the sub-total and grand total are redundant, so I only want to show one of them. I...
1
by: cityrock | last post by:
Hi everyone, I have been searching 3 days stright for an answer, with no luck, so I decided to ask it out loud myself. Here is my problem. I am using a report as a catalog for my company. The...
1
by: David Horowitz | last post by:
Hi folks. I need to create a report that has a Group Header that pulls certain data from the Detail section. It's something like this: +--Report---------------------------------------- |...
3
by: fonzie | last post by:
On my report I am currently using page footer to display some disclaimer information. No matter how many records show up in the detail section, the page footer is always at the bottom of the page....
3
by: gardner | last post by:
Please help. I am trying to count something in a Group Footer using a Text Box. If what I am doing is not doable, or there is a better way to structure this please tell me. Here is the situation:...
1
by: PDH | last post by:
I have sumation in my group footer that I would like to hide when the sumation = zero. I am relatively new to MS access and my current attempt involved the onformat and the following expression: ...
3
by: carmela_wong | last post by:
I am trying to output a report in which I show the total number of people if groupfooter is "STAFF" but not if it is "ATTENDEES". The report will say: STAFF: Staff1....... Staff2...... Total...
1
by: bullfrog83 | last post by:
I have a form that contains parameters for a report. After the user clicks Preview I have code that set's the Where clause for the report's record source. Once the report opens I close the parameter...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.