dynamic Grouping Levels

P

Peter Hafner

Hi there,

I want to create reports which have a dynamic number(1 to 4) of grouping
levels depending on a user action (listbox).

With CreateGroupLevel I have to create the layout of headers, footer,
details etc. by code (too difficult).

Therefore I tried to create a Report with 4 grouping levels and deleting
the unneeded levels on the open event with Me.GroupLevel(n).GroupFooter
= False which is not working.

Hiding the Footers etc. still requires to set a controlSource for the
grouping level (which one if the user don´t want one??).

Any ideas how to solve this problem?

Thanx,

Peter
 
M

Marshall Barton

Peter said:
I want to create reports which have a dynamic number(1 to 4) of grouping
levels depending on a user action (listbox).

With CreateGroupLevel I have to create the layout of headers, footer,
details etc. by code (too difficult).

A bad idea anyway.

Therefore I tried to create a Report with 4 grouping levels
[snip]

On the right track now.

Hiding the Footers etc. still requires to set a controlSource for the
grouping level (which one if the user don´t want one??).

Use the report's Open event to change the group level's
ControlSource property and make the unused ones invisible.
If you don't want a group level to do any sorting, then set
its control source to a constant expression such as =1. For
example:

Me.GroupLevel(0).ControlSource = "thisfield"
Me.GroupLevel(1).ControlSource = "thatfield"
Me.GroupLevel(2).ControlSource = "otherfield"
Me.GroupLevel(3).ControlSource = "=1"
Me.Section(11).Visible = False 'hide header
Me.Section(12).Visible = False 'hide footer
 
P

Peter Hafner

Marshall said:
Peter said:
I want to create reports which have a dynamic number(1 to 4) of grouping
levels depending on a user action (listbox).

With CreateGroupLevel I have to create the layout of headers, footer,
details etc. by code (too difficult).


A bad idea anyway.


Therefore I tried to create a Report with 4 grouping levels

[snip]

On the right track now.


Hiding the Footers etc. still requires to set a controlSource for the
grouping level (which one if the user don´t want one??).


Use the report's Open event to change the group level's
ControlSource property and make the unused ones invisible.
If you don't want a group level to do any sorting, then set
its control source to a constant expression such as =1. For
example:

Me.GroupLevel(0).ControlSource = "thisfield"
Me.GroupLevel(1).ControlSource = "thatfield"
Me.GroupLevel(2).ControlSource = "otherfield"
Me.GroupLevel(3).ControlSource = "=1"
Me.Section(11).Visible = False 'hide header
Me.Section(12).Visible = False 'hide footer
Hi Marsh,

thanks a lot.
It looks like it is working. I just thought that I have missed a more
elegant way to do that.
Maybe you can explain why setting ControlSource to =1 is working, i.e.
is doing nothing but also not generating any error?

Thanks again for the help,

Peter
 
M

Marshall Barton

Peter said:
Marshall said:
Peter said:
I want to create reports which have a dynamic number(1 to 4) of grouping
levels depending on a user action (listbox).

With CreateGroupLevel I have to create the layout of headers, footer,
details etc. by code (too difficult).


A bad idea anyway.


Therefore I tried to create a Report with 4 grouping levels

[snip]

On the right track now.


Hiding the Footers etc. still requires to set a controlSource for the
grouping level (which one if the user don´t want one??).


Use the report's Open event to change the group level's
ControlSource property and make the unused ones invisible.
If you don't want a group level to do any sorting, then set
its control source to a constant expression such as =1. For
example:

Me.GroupLevel(0).ControlSource = "thisfield"
Me.GroupLevel(1).ControlSource = "thatfield"
Me.GroupLevel(2).ControlSource = "otherfield"
Me.GroupLevel(3).ControlSource = "=1"
Me.Section(11).Visible = False 'hide header
Me.Section(12).Visible = False 'hide footer
Hi Marsh,

thanks a lot.
It looks like it is working. I just thought that I have missed a more
elegant way to do that.
Maybe you can explain why setting ControlSource to =1 is working, i.e.
is doing nothing but also not generating any error?


It is perfectly legal to group on an expression. For
example, it's not uncommon to sort/group on something like
=[LastName] & "~" & [FirstName]

The expression:
=1
is just about the simplest expression you can get and since
it doesn't change from one record to another, it will not
have any effect on the order of the records. Your use of it
is only one of several situations where this can be useful.
 
P

Peter Hafner

Marshall said:
Peter Hafner wrote:

Marshall Barton wrote:

Peter Hafner wrote:


I want to create reports which have a dynamic number(1 to 4) of grouping
levels depending on a user action (listbox).

With CreateGroupLevel I have to create the layout of headers, footer,
details etc. by code (too difficult).


A bad idea anyway.




Therefore I tried to create a Report with 4 grouping levels

[snip]

On the right track now.




Hiding the Footers etc. still requires to set a controlSource for the
grouping level (which one if the user don´t want one??).


Use the report's Open event to change the group level's
ControlSource property and make the unused ones invisible.
If you don't want a group level to do any sorting, then set
its control source to a constant expression such as =1. For
example:

Me.GroupLevel(0).ControlSource = "thisfield"
Me.GroupLevel(1).ControlSource = "thatfield"
Me.GroupLevel(2).ControlSource = "otherfield"
Me.GroupLevel(3).ControlSource = "=1"
Me.Section(11).Visible = False 'hide header
Me.Section(12).Visible = False 'hide footer

Hi Marsh,

thanks a lot.
It looks like it is working. I just thought that I have missed a more
elegant way to do that.
Maybe you can explain why setting ControlSource to =1 is working, i.e.
is doing nothing but also not generating any error?



It is perfectly legal to group on an expression. For
example, it's not uncommon to sort/group on something like
=[LastName] & "~" & [FirstName]

The expression:
=1
is just about the simplest expression you can get and since
it doesn't change from one record to another, it will not
have any effect on the order of the records. Your use of it
is only one of several situations where this can be useful.

Now we know! Thank you,

Peter
 

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