• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 418
  • Last Modified:

Hide a subreport based on the result from a checkbox in the main form

I have a report with several subreports that show up on the report based on if they have data in a specific table or not.  I need to be able to hide one of these subreports in the main report if I have a check box selected or not selected in the main form.  Can this be done by VBA code in the report?  I am not sure how for it to check the main form.  
0
thirdrockit
Asked:
thirdrockit
  • 3
  • 2
2 Solutions
 
GRayLCommented:
in the Current event of the checkbox named chkBox:

Private Sub chkBox_Current()
  If Me!chkBox Then
    Me.Form!sfmName.Visible = False
  Else
    Me.Form!sfmName.Visible = True
  End If
End Sub
0
 
thirdrockitAuthor Commented:
I am not hiding a subform, I need to hide a subreport that is within a big report that has a lot of resume data in it.  I have a resume form that has several checkboxs so that my resume data can be selectable for what I want printed.  The data, once selected on the form, is then sent to a table.  The report, with the multiple subreports, pulls the info from the table.  Everything works great except now I have some data going to the table that will automatically cause the subreport to show.  I cannot stop the data from making it to the table so I need to just hide the subreport instead.
0
 
clarkscottCommented:
Create a public variable:
public glbHideSub as boolean

In the code prior to opening the report -
If {your condition = true) then
    glbHideSub = true
end if

In the report ON OPEN EVENT
me.YourSubReport.visible = not glbHideSub


don't forget to 'clear' the variable on closing the report:
glbHideSub = false

Scott C
0
NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

 
GRayLCommented:
OK in my code where you see Form, replace it (it it there two time) with Report
0
 
thirdrockitAuthor Commented:
Thanks for you help !!! I figured out how to do it so that when the box is checked it changes the data that the report is pulling from.   Unless the box is checked the data will not be in the table, and the sub report will not show because there is no data. I am awarding you all the points anyways because I may still be able to use your examples.
0
 
GRayLCommented:
Thanks, glad to help.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now