Turn Grouping on / off

Opengrave

Registered User.
Local time
Yesterday, 18:17
Joined
Sep 6, 2001
Messages
70
I have a report that list all children in all grades. The users would like to be able to print the report as it is now or have the report grouped by grade and gender. I have created a field in the query that concatenates grade and gender so I do have a field to group on. The problem is that I can't seem to find a way to turn the report grouping on and off from code.

I have researched GroupOn property, GroupHeader/Footer property, and the CreateGroupLevel method. The CreateGroupLevel method seems to do what I need but you have to switch to design view to make it work and because of the way my users edit these reports I'm afraid this is a bad option for me.

Does anyone know of any way you can turn report grouping on and off from VBA without switching to design view?

(If this fails I'll just create a separate report with grouping turned on - I'd just like to do this without an extra report if possible.)

As always any help is appreciated.
 
How do they open the report? I would think that you have a GUI that they use to open it, so add a few controls to it that allow for them to group by certain fields if they want to. Then open the report with conditions set on thier selections or lack of selections.

This would allow you to use 1 report for all of the formats. One option group should cover your needs, then add a CASE SELCET (or SECLECT CASE i always get it confused) stament that will open the report with the proper grouping.
 
No Grouping
 

Attachments

  • nogrouping.gif
    nogrouping.gif
    25 KB · Views: 230
Grouped.
 

Attachments

  • grouped.gif
    grouped.gif
    25.5 KB · Views: 228
jeremie_ingram said:
How do they open the report? I would think that you have a GUI that they use to open it, so add a few controls to it that allow for them to group by certain fields if they want to. Then open the report with conditions set on thier selections or lack of selections.

This would allow you to use 1 report for all of the formats. One option group should cover your needs, then add a CASE SELCET (or SECLECT CASE i always get it confused) stament that will open the report with the proper grouping.

I've created the GUI and have all of the controls to do everything I need with tha data and get the inputs I need for the report formatting.

The problem I have is with actually formatting the report using code. I want to switch from the no grouping example to the grouped example using code.

The real question is - is there any code that will allow me to display or hide txtGenderGroup Header without first switching to design mode?
 
In the ON OPEN event for the report, you could add the code to make the group headers visible property false or true.

Me.GroupHeader0.Visible = True

or

Me.GroupHeader0.Visible = False

You would have a refrence like

If form1.chkbx1 = True then
Me.GroupHeader0.Visible = True
Else
Me.GroupHeader0.Visible = False
end if
 
Me.GroupHeader0.Visible = True

Thats it! I knew it had to be easy I just didn't think it was that easy. Thanks for the help!!
 

Users who are viewing this thread

Back
Top Bottom