I am trying to make one report serve multiple functions. I had to add an
additional grouping level to satisfy a request from one end user. I hide
this grouping based on a value in a combo box. This works except it keeps
sorting by this group level, even though it is not visible. This sorting
will not work for the other end user.
How can I make the report ignore the sorting when the group is not visible?
Paul Hammond
Richmond, VA
Is this the only GroupLevel in the Sortin'n'Grouping dialog?
If so, the report has to sort by something. Perhaps the primary key would be
a good candidate if nothing else is obvious.
If not, you can set the unused lower GroupLevel to the same field as your
primary GroupLevel. That should cause it to sort only on the one field.
Sounds like you have already figured out how to set the ControlSource of the
GroupLevel at runtime.

Signature
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
>I am trying to make one report serve multiple functions. I had to add an
> additional grouping level to satisfy a request from one end user. I hide
[quoted text clipped - 8 lines]
> Paul Hammond
> Richmond, VA
Paul Hammond - 18 Oct 2005 22:22 GMT
> Sounds like you have already figured out how to set the ControlSource of the
> GroupLevel at runtime.
Actually that hadn't occured to me, but it worked like magic the first time.
You can't see the big smile on my face!
Thanks loads,
Paul
> Is this the only GroupLevel in the Sortin'n'Grouping dialog?
>
[quoted text clipped - 19 lines]
> > Paul Hammond
> > Richmond, VA
Paul Hammond - 25 Oct 2005 20:26 GMT
Problem:
I have started getting an error while doing this.
"You can't set the Control Source property in print preview or after
printing has started."
Here's my code:
Private Sub Report_Open(Cancel As Integer)
If Form_frmMain.cboSource = 1 Then
Me.GroupHeader4.Visible = False
Me.GroupFooter1.Visible = False
Me.GroupLevel(2).ControlSource = "[ProdCode]"
End If
end sub
It's very confusing, because I tested this successfully previously.
Paul

Signature
Paul
> Is this the only GroupLevel in the Sortin'n'Grouping dialog?
>
[quoted text clipped - 19 lines]
> > Paul Hammond
> > Richmond, VA
Allen Browne - 26 Oct 2005 03:46 GMT
Not sure what's happening there, Paul.
My page explaining the general procedure is:
http://allenbrowne.com/ser-33.html
Presumably you already have 3 levels defined in the Sorting and Grouping
dialog? (It's zero-based, so GroupLevel(2) is the 3rd one.)

Signature
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
> Problem:
> I have started getting an error while doing this.
[quoted text clipped - 43 lines]
>> > Paul Hammond
>> > Richmond, VA
Paul Hammond - 26 Oct 2005 14:11 GMT
I've discovered what the problem is.
The report I was trying to set the Control Source of was a subreport. The
error did not occur when I ran the report solo.
Paul

Signature
> Not sure what's happening there, Paul.
>
[quoted text clipped - 51 lines]
> >> > Paul Hammond
> >> > Richmond, VA