Switching off grouping *and sorting* in a report?

  • Thread starter Thread starter kiln
  • Start date Start date
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?
 
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
. . .
 
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
 
Back
Top