grouping in code

L

Len

I have a report with 2 groupheaders and footers.
The groups are WHS and Class.
I am trying to use this one report as the basis for several.
Using code I am trying to group the following ways
WHS then by Class
Whs only
Class then WHS
Class only
I tried the below code but even when I set the second group to visible =
false
Next 2 lines set from a form
gstrGrpLevel0="Class"
gstrGrpLevel1="WHS"
(gfClass is the name of a footer)
Private Sub Report_Open(Cancel As Integer)
Me!lblSubTitle.Caption = gstrSubTitle
Me.gfClass.Visible = gbClass
Me.ghClass.Visible = gbClass
Me.gfWHS.Visible = gbWHS
Me.ghWHS.Visible = gbWHS
Me.Detail.Visible = gbDetail
Me.GroupLevel(0).ControlSource = gstrGrpLevel0
Me.GroupLevel(1).ControlSource = gstrGrpLevel1
end sub
I sum on the same field in both footers.
But say if I try Class only I still breaks in class every time WHS changes.
Anybody have a sample or link to more info on this subject.
Thanks
Len
 
M

Marshall Barton

Len said:
I have a report with 2 groupheaders and footers.
The groups are WHS and Class.
I am trying to use this one report as the basis for several.
Using code I am trying to group the following ways
WHS then by Class
Whs only
Class then WHS
Class only
I tried the below code but even when I set the second group to visible =
false
Next 2 lines set from a form
gstrGrpLevel0="Class"
gstrGrpLevel1="WHS"
(gfClass is the name of a footer)
Private Sub Report_Open(Cancel As Integer)
Me!lblSubTitle.Caption = gstrSubTitle
Me.gfClass.Visible = gbClass
Me.ghClass.Visible = gbClass
Me.gfWHS.Visible = gbWHS
Me.ghWHS.Visible = gbWHS
Me.Detail.Visible = gbDetail
Me.GroupLevel(0).ControlSource = gstrGrpLevel0
Me.GroupLevel(1).ControlSource = gstrGrpLevel1
end sub
I sum on the same field in both footers.
But say if I try Class only I still breaks in class every time WHS changes.


Your four cases should be set this way:

gstrGrpLevel0="WHS"
gstrGrpLevel1="Class"

gstrGrpLevel0="WHS"
gstrGrpLevel1="=1"

gstrGrpLevel0="Class"
gstrGrpLevel1="WHS"

gstrGrpLevel0="Class"
gstrGrpLevel1="=1"
 
M

Marshall Barton

Len said:
Thanks I'll try it.
What does the =1 mean for the single group report.?

Setting the group level's control source to a constant
expression effectively disables the level's sorting.
Sorting on the value 1 just isn't going to do much to the
order of the data.
--
Marsh
MVP [MS Access]


 
L

Len

Ok Thanks that works great !
But how can I still set a secondary sort within the one group
For instance if I group by warehouse I still neeed to sort by itemnumber
within warehouse.
Thanks once again
Len
 
M

Marshall Barton

Len said:
Ok Thanks that works great !
But how can I still set a secondary sort within the one group
For instance if I group by warehouse I still neeed to sort by itemnumber
within warehouse.


What happend to Class? Are you asking how to sort on item
instead of Class when Class is not being used?? If so, why
not just set the second group level to ItemNumber??? I.e.
. . .
gstrGrpLevel0="WHS"
gstrGrpLevel1="ItemNumber"
. . .



 

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