Switching off grouping *and sorting* in a report?

K

kiln

I have a report that has three GroupLevels and then a detail section.
Example:

Country
State
City
Person (detail)

The calling form has three checkboxes, one for each GroupLevel, and the
user checks the levels which are to be shown on the report. So they
could check just Country, and it'd list people grouped by country; or
check both Country and State, have it group by both. The reports on open
event has code that sets the visible property for each group level
according to the matching checkbox on the calling form. Fine...but of
course the report still sorts by the hidden group levels, IOW there is
always a sort by Country in effect, even if the group level is hidden.

So far the only way I've been able to envision getting rid of the
sorting for hidden group levels is to reassign the ControlSource
property to match the next visible group level. So if the first group by
to be shown is City, reassign both Country and State ControlSource's to
City. Is there a simpler way to implement this?
 
M

Marshall Barton

kiln said:
I have a report that has three GroupLevels and then a detail section.
Example:

Country
State
City
Person (detail)

The calling form has three checkboxes, one for each GroupLevel, and the
user checks the levels which are to be shown on the report. So they
could check just Country, and it'd list people grouped by country; or
check both Country and State, have it group by both. The reports on open
event has code that sets the visible property for each group level
according to the matching checkbox on the calling form. Fine...but of
course the report still sorts by the hidden group levels, IOW there is
always a sort by Country in effect, even if the group level is hidden.

So far the only way I've been able to envision getting rid of the
sorting for hidden group levels is to reassign the ControlSource
property to match the next visible group level. So if the first group by
to be shown is City, reassign both Country and State ControlSource's to
City. Is there a simpler way to implement this?


Setting the GroupLevel.ControlSource is the only way to
affect how they behave. It may be a trifle bit easier to
set it to a constant expression instead of the same field as
another level.

If Not Forms!yourform.chkState Then
Me.GroupLevel(1).ControlSource = "=1"
Me.Section(7).Visible = False
End If
. . .
 
K

kiln

Setting the GroupLevel.ControlSource is the only way to
affect how they behave. It may be a trifle bit easier to
set it to a constant expression instead of the same field as
another level.

If Not Forms!yourform.chkState Then
Me.GroupLevel(1).ControlSource = "=1"
Me.Section(7).Visible = False
End If
. . .

OK, thanks Marshall
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top