Can I programmatically hide subreports?


R

Robin

I have a report which contains a number of subreports and I wish to
show/hide these based on user checkbox choices on a form before the report
is opened. I can manually hide the subreports by changing their visible
property. Is this possible from vbe and if so, do the subreports (or the
main report) need to be open at the time, and could someone possibly give me
a clue as to the syntax?

I seem to be going round in circles at the moment!

Thx

Robin
 
Ad

Advertisements

S

SusanV

in the main form's on current event (set the actual control names for your
project)


Me.YourSubformName.Visible = (Me.YourCheckboxName = true)
 
G

Guest

Robin:

In the Format event procedure of whichever section of the parent report the
subreport is in put:

On Error resume Next
SubReportControl.Visible = Forms!YourForm!YourCheckBox

If the check box is checked (TRUE) the subreport will be visible, if not
(FALSE) it will be hidden. Note that SubReportControl is the name of the
subreport control in the parent report, i.e. the control which houses the
subreport, not the name of its underlying Report object.

The error handling means the line will be ignored if the form is not open,
e.g. if the report is opened directly from the database window.

Ken Sheridan
Stafford, England
 
R

Robin

Thank you Ken - worked perfectly!

I perhaps should have added to my question, the fact that I wasn't opening
the main report directly, but was using OutputTo acOutputReport to export
the report to a rtf document - but this solution still works!

Thanks again.

R
 
R

Robin

Thank you! I was struggling to achieve this from code relating to the check
boxes - You made me realise that I should have been looking at code for the
report.

Thx.

Robin
 
Ad

Advertisements

Ad

Advertisements


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