Formatting a subreport on the fly

  • Thread starter Thread starter Max Moor
  • Start date Start date
M

Max Moor

Hi All,
So, round two...

I have a report that is opened by a "pre-report config" form, where I
set various formatting things. When I open the report, in its Open event
code, I refer to various controls on the "config form," and set things like
the GroupLevel(x).ControlSource properties and the visibility of various
report controls.

This report has a sub-report in its detail section. I want to set it
up the same way, by referring to my "pre-report config" form. The problem
is that I get errors like:

"You can't set the control source property in print preview or after
printing has started."

For the main report, I open it hidden, do the formatting in the Open
event code, then set it visible, and everybody is happy. What do I do for
the subreport???

With Allen's help, I got the filtering of the subreport's base query
working, but there's still all the formatting stuff... HELP! :-)

- Max
 
Max said:
I have a report that is opened by a "pre-report config" form, where I
set various formatting things. When I open the report, in its Open event
code, I refer to various controls on the "config form," and set things like
the GroupLevel(x).ControlSource properties and the visibility of various
report controls.

This report has a sub-report in its detail section. I want to set it
up the same way, by referring to my "pre-report config" form. The problem
is that I get errors like:

"You can't set the control source property in print preview or after
printing has started."


A subreport's Open event is triggered each time the
subreport appears (i.e. for each main report detail), but
you can only set certain properties such as ControlSource
the first time.

Try using this kind of logic in the subreport's Open event:

Sub Report_Open(
Static Initialized As Boolean
If Not Initialized Then
Me.GroupLevel(x).ControlSource = . . .
. . .
Initialized = True
End If
 
Static Initialized As Boolean
If Not Initialized Then
Me.GroupLevel(x).ControlSource = . . .
. . .
Initialized = True

That's the trick. Thanks Marsh. Works like a charm.

- Max
 
Back
Top