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.  
thirdrockitAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.