Combining Multiple Reports On Demand

  • Thread starter Thread starter magmike
  • Start date Start date
M

magmike

We have a report outline that has eight sections. Rarely do we need
all eight. Because every client is different, sometimes we may need
sections 1,2,5,6,7 and others we may need something completely
different.

My goal is to create a form requesting the report with check boxes the
user selects or list boxes to determine which portions of the report
actually show in the final document. Is there a way to do this on one
report - or a way to combine multiple reports into one final document
on demand?

Thanks in advance!
magmike
 
Mike,

I've never done this, but you might try the following.

1. I think you could set the "sections" of your report as subreports in a
report. Then, in the detail sections Format event, you might be able to set
the height of these subreports to zero and their CanGrow property to False

Alternately, you might consider

2. Take a look at the CreateReportControl method in Access help. It gives
an example of creating a control on a form (using the CreateControl) method,
but implies that CreateReportControl works the same way.

I've never done this, but the implication is that you could add some code
behind a command button that would add controls (I'd use subreports) to your
report based on what items are checked.

Then, you could open the form in design view (again with code), and set the
ControlSource and master/child property values for the for these subforms.

I know this wasn't much help, bit it might give you some ideas where to
start looking.
--
HTH
Dale

Don''t forget to rate the post if it was helpful!

email address is invalid
Please reply to newsgroup only.
 
If you are using the word 'sections' in the sense of a Section property of a
report, e.g. detail, group header etc its simple, you just put a line of code
in the section's Format event procedure to cancel the section:

Cancel = Not Forms!YourForm!TheRelevantCheckBox

Be sure the values of the checkboxes are all False (unchecked) or True
(checked) by default on your form, not Null (greyed out).

However, I suspect you are using the word more generically, in which case
setting the control's Visible property to False as Dale suggests is probably
the best bet, at the same time shrinking them by setting their CanShrink
property to True. If you can't do it with subreports then you can do this
for individual controls, so in the Format event procedure of the section
containing the controls you'd have a series of lines of code which
hides/shows each control, each along these lines:

Me.SomeControl.Visible = Forms!YourForm!TheRelevantCheckBox

As well as bound controls you might need to show/hide labels in the same way.

A more economical way would be to set the Tag property of each control to
its 'section' name, e.g. Section1. For controls you want to show in every
case set it to AllSections. Then in the Format event procedure of whichever
report section the controls are in loop through its Controls collection like
so:

Dim ctrl As Control

For Each ctrl In Me.Controls
Select Case ctrl.Tag
Case "AllSections"
ctrl.Visible = True
Case "Section1"
ctrl.Visible = Forms!YourForm!chkSection1
Case "Section2"
ctrl.Visible = Forms!YourForm!chkSection2
'''<and so on>'''
End Select
Next ctrl

Don't forget that you can only shrink a control if there are no
non-shrinking controls alongside it, including graphical elements such as
lines.

Ken Sheridan
Stafford, England
 
Back
Top