make report sections visible or not

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

Guest

Hi Everyone
I have a form where I imput parameters for a query that my report is based
on.
I also created a frame with following check boxes:
Print all, Print monthly totals, Print Grand Totals. I have a comand button
which opens the report with all sections visible. I'd like to be able to make
sections of the report not visible depending on choice in my frame.
How do I go about that?

thanks
Barb
 
Use the Open event procedure of the report to set the Visible property of
the sections of the report, depending on the value of the option group in
the form.

This kind of thing:

Private Sub Report_Open(Cancel As Integer)
If CurrentProject.AllForms("Form1").IsLoaded Then
Select Case Forms("Form1")![Frame0].Value
Case 1
Me.Section(acDetail).Visible = True
Case 2
Me.Section(acDetail).Visible = False
Case 3
...
End Select
End If
End Sub
 
Hi Allen
Thank you very much, works great.
But could you tell me how do I reference GroupHeader0, GroupHeader1...
acDetail is detail section, but I'm stumped with all the others.

thanks
Barb

Allen Browne said:
Use the Open event procedure of the report to set the Visible property of
the sections of the report, depending on the value of the option group in
the form.

This kind of thing:

Private Sub Report_Open(Cancel As Integer)
If CurrentProject.AllForms("Form1").IsLoaded Then
Select Case Forms("Form1")![Frame0].Value
Case 1
Me.Section(acDetail).Visible = True
Case 2
Me.Section(acDetail).Visible = False
Case 3
...
End Select
End If
End Sub

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

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

Barb said:
Hi Everyone
I have a form where I imput parameters for a query that my report is based
on.
I also created a frame with following check boxes:
Print all, Print monthly totals, Print Grand Totals. I have a comand
button
which opens the report with all sections visible. I'd like to be able to
make
sections of the report not visible depending on choice in my frame.
How do I go about that?

thanks
Barb
 
Hi Everyone
I have a form where I imput parameters for a query that my report is based
on.
I also created a frame with following check boxes:
Print all, Print monthly totals, Print Grand Totals. I have a comand button
which opens the report with all sections visible. I'd like to be able to make
sections of the report not visible depending on choice in my frame.
How do I go about that?

thanks
Barb

By Frame, do you mean an Option Group?
If so, code the Format event of each report section affected:
Me.Visible = forms!FormName!OptionGroupName = 1 '(Or whatever the
option value is to hide that particular section.)

The form must be open while the report is run.
 
In the code window, press F2. Access opens the Object Browser.
Search for acDetail.
Access shows it as a member of AcSection.
Other members include:
- acHeader (the report header), with value 1
- acFooter (the report footer), with value 2.
- acPageHeader = 3
- acPageFooter = 4
- acGroupLevel1Header = 5
- acGroupLevel2Footer = 6

The constants only go as far as acGroupLeve2Footer (8), but you can see the
sequence, and figure them out from there.

You can create your own constants for the others if you wish:
Const acGroupLevel3Header = 9
Const acGroupLevel4Footer = 10
and so on.

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

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

Barb said:
Hi Allen
Thank you very much, works great.
But could you tell me how do I reference GroupHeader0, GroupHeader1...
acDetail is detail section, but I'm stumped with all the others.

thanks
Barb

Allen Browne said:
Use the Open event procedure of the report to set the Visible property of
the sections of the report, depending on the value of the option group in
the form.

This kind of thing:

Private Sub Report_Open(Cancel As Integer)
If CurrentProject.AllForms("Form1").IsLoaded Then
Select Case Forms("Form1")![Frame0].Value
Case 1
Me.Section(acDetail).Visible = True
Case 2
Me.Section(acDetail).Visible = False
Case 3
...
End Select
End If
End Sub

Barb said:
Hi Everyone
I have a form where I imput parameters for a query that my report is
based
on.
I also created a frame with following check boxes:
Print all, Print monthly totals, Print Grand Totals. I have a comand
button
which opens the report with all sections visible. I'd like to be able
to
make
sections of the report not visible depending on choice in my frame.
How do I go about that?
 
thank you, now I'm a bit smarter...

Barb

Allen Browne said:
In the code window, press F2. Access opens the Object Browser.
Search for acDetail.
Access shows it as a member of AcSection.
Other members include:
- acHeader (the report header), with value 1
- acFooter (the report footer), with value 2.
- acPageHeader = 3
- acPageFooter = 4
- acGroupLevel1Header = 5
- acGroupLevel2Footer = 6

The constants only go as far as acGroupLeve2Footer (8), but you can see the
sequence, and figure them out from there.

You can create your own constants for the others if you wish:
Const acGroupLevel3Header = 9
Const acGroupLevel4Footer = 10
and so on.

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

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

Barb said:
Hi Allen
Thank you very much, works great.
But could you tell me how do I reference GroupHeader0, GroupHeader1...
acDetail is detail section, but I'm stumped with all the others.

thanks
Barb

Allen Browne said:
Use the Open event procedure of the report to set the Visible property of
the sections of the report, depending on the value of the option group in
the form.

This kind of thing:

Private Sub Report_Open(Cancel As Integer)
If CurrentProject.AllForms("Form1").IsLoaded Then
Select Case Forms("Form1")![Frame0].Value
Case 1
Me.Section(acDetail).Visible = True
Case 2
Me.Section(acDetail).Visible = False
Case 3
...
End Select
End If
End Sub

Hi Everyone
I have a form where I imput parameters for a query that my report is
based
on.
I also created a frame with following check boxes:
Print all, Print monthly totals, Print Grand Totals. I have a comand
button
which opens the report with all sections visible. I'd like to be able
to
make
sections of the report not visible depending on choice in my frame.
How do I go about that?
 

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

Back
Top