Dynamic Sort order

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.
 
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
 
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
 
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.)

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Paul Hammond said:
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
--

Paul

Allen Browne said:
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.
 
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
--

Allen Browne said:
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.)

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Paul Hammond said:
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
--

Paul

Allen Browne said:
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.

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
 
Back
Top