Hiding Report sections with form checkbox and vba

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

Guest

A while ago I posted a need to hide a report detail section using a checkbox
'SumView' on a form. The original code provided to me (which worked great!)
is as follows:

Private Sub Report_Open(Cancel As Integer)
Const strcForm As String = "FMinvxMENU"
If CurrentProject.AllForms(strcForm).IsLoaded Then
Me.Section(acDetail).Visible = _
Nz(Forms(strcForm)!SumView.Value, False)
End If
End Sub

I have three other header sections above the details section (PartNumber
Header, Site Header, Area Header) that I want to be able to hide as well
using buttons on a form.

How can I expand this code to hide any or all of the details and section
headers?
 
Ernie,

Do you mean a separate checkbox on the form for each section? Try it
like this...

Private Sub Report_Open(Cancel As Integer)
Me.Section(acDetail).Visible = Forms!FMinvxMENU!SumView
Me.Section(acGroupLevel1Header).Visible = Forms!FMinvxMENU!PartView
Me.Section(acGroupLevel2Header).Visible = Forms!FMinvxMENU!SiteView
Me.Section(acGroupLevel3Header).Visible = Forms!FMinvxMENU!AreaView
End Sub
 
Thanks. I'll give it a try and let you know.

Steve Schapel said:
Ernie,

Do you mean a separate checkbox on the form for each section? Try it
like this...

Private Sub Report_Open(Cancel As Integer)
Me.Section(acDetail).Visible = Forms!FMinvxMENU!SumView
Me.Section(acGroupLevel1Header).Visible = Forms!FMinvxMENU!PartView
Me.Section(acGroupLevel2Header).Visible = Forms!FMinvxMENU!SiteView
Me.Section(acGroupLevel3Header).Visible = Forms!FMinvxMENU!AreaView
End Sub
 
That works well for the detail and footers, but don't set
the headers to not visible like that - there is an obscure
bug that sometimes make the report go into an infinite loop.


The PrintSection property is the original way to control
printing of sections. If you want to set section headers
not visible, use code like this in the format events:

Private Sub GroupHeader0_Format(Cancel As Integer, FormatCount As Integer)
PrintSection = Forms!FMinvxMENU!PartView
End Sub

(david)
 

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