Add or Remove Section Programatically

  • Thread starter Thread starter dmeiser
  • Start date Start date
D

dmeiser

Hello,

I have a series of reports that are all essentially the same except for
an extra grouping. I figured that, if I set the Section to Not Visible
(Visible = False) then the grouping would also disappear. Except that
I was wrong.

So, what I think I need to do is find a way to say something like
Section(#).Grouping = False, which I noticed is not a valid method, or
just to remove the section altogether for a while.

Any thoughts?

Thanks,
DAVE
 
dmeiser said:
I have a series of reports that are all essentially the same except for
an extra grouping. I figured that, if I set the Section to Not Visible
(Visible = False) then the grouping would also disappear. Except that
I was wrong.

So, what I think I need to do is find a way to say something like
Section(#).Grouping = False, which I noticed is not a valid method, or
just to remove the section altogether for a while.


If you want the report sorted by the grouping field, then
you need to use the report's Open event procedure to set the
corresponding GroupLevel's ControlSource to =""

You will still get a group header/footer for the "" group,
so you still need to make it invisible.

The code will be something like:

If <some condition> Then
Me.GroupLevel(NN).ControlSource = ""
Me.Section(KK).Visible = False
End If
 
Access wouldn't let me set the ControlSource to "", but I was able to
work around that by just setting the ConstrolSource equal to the next
ControlSource. Essentially, I have 3 control sources, and I just
doubled up the second when I don't want grouping by the first.
 
dmeiser said:
Access wouldn't let me set the ControlSource to "", but I was able to
work around that by just setting the ConstrolSource equal to the next
ControlSource. Essentially, I have 3 control sources, and I just
doubled up the second when I don't want grouping by the first.


That will usually work (sometimes you might need to set it
to the previous group), but I mispoke before, it should be

Me.GroupLevel(NN).ControlSource = "=1"
 
Back
Top