|
 |
access thread: set subreport filter = main report filter
Message #1 by "Carol Mandra" <Carol_Mandra@r...> on Mon, 18 Jun 2001 16:47:18 -0400
|
|
I'm put this code in the onOpen event and/or the OnActivate event in the
main form:
'set the subform's filter equal to the main form's filter
Me.subrpt_OfficeLevel.Report.Filter = Me.Filter
I keep getting error messages.
I can't get the filter set in the subform's open event either with this
code:
me.filter = me.parent.filter
How can I do this? my subreport is not linked by master/child fields. It
is in the report footer.
Help! Carol
Message #2 by "Carol Mandra" <carol_mandra@r...> on Tue, 19 Jun 2001 14:29:41
|
|
>
> I'm put this code in the onOpen event and/or the OnActivate event in the
> main form:
> 'set the subform's filter equal to the main form's filter
> Me.subrpt_OfficeLevel.Report.Filter = Me.Filter
> I keep getting error messages.
>
> I can't get the filter set in the subform's open event either with this
> code:
> me.filter = me.parent.filter
>
> How can I do this? my subreport is not linked by master/child fields. It
> is in the report footer.
> Help! Carol
I found a way to do it. The report has to be open to set its properties. I
don't know if I can set properties otherwise. Does anyone know if it can be
done if the report is closed?
In report_open of the Main report's module:
'set the subform's filter equal to the main form's filter
Dim doc As Document, con As Container
Set con = db.Containers("Reports")
'Application.Echo False
For Each doc In con.Documents
If doc.Name = "subrptSectionSummary_Office" Then
DoCmd.OpenReport doc.Name, acViewDesign
Reports(doc.Name).Filter = Me.Filter
Reports(doc.Name).FilterOn = True
DoCmd.Save
DoCmd.Close acReport, doc.Name
End If
Next
Application.Echo True
in report_activate: docmd.requery me.name
>
>
Message #3 by tony.scott@n... on Tue, 19 Jun 2001 14:53:47
|
|
Carol,
For what you need to do, you will need to understand the Sequence of
Events occurring when a Report opens.
The Open Event, simply Opens the Object. The object will then load it's
recordsource.
> >
> > I'm put this code in the onOpen event and/or the OnActivate event in
the
> > main form:
> > 'set the subform's filter equal to the main form's filter
> > Me.subrpt_OfficeLevel.Report.Filter = Me.Filter
> > I keep getting error messages.
> >
> > I can't get the filter set in the subform's open event either with
this
> > code:
> > me.filter = me.parent.filter
> >
> > How can I do this? my subreport is not linked by master/child fields.
It
> > is in the report footer.
> > Help! Carol
>
> I found a way to do it. The report has to be open to set its properties.
I
> don't know if I can set properties otherwise. Does anyone know if it can
be
> done if the report is closed?
>
> In report_open of the Main report's module:
>
> 'set the subform's filter equal to the main form's filter
> Dim doc As Document, con As Container
> Set con = db.Containers("Reports")
> 'Application.Echo False
> For Each doc In con.Documents
> If doc.Name = "subrptSectionSummary_Office" Then
> DoCmd.OpenReport doc.Name, acViewDesign
> Reports(doc.Name).Filter = Me.Filter
> Reports(doc.Name).FilterOn = True
> DoCmd.Save
> DoCmd.Close acReport, doc.Name
> End If
> Next
> Application.Echo True
>
> in report_activate: docmd.requery me.name
> >
> >
Message #4 by tony.scott@n... on Tue, 19 Jun 2001 15:03:05
|
|
Carol,
To achieve your goal, you will need to understand the sequence of events
when a Report Opens.
For the main report::
Open - Activate - Close - Deactivate
For the Detail (where the data is displayed) AND the Report
Open (report) - Activate (report) - Format (report section) - Print
(report section) - Close (report) - Deactivate (report)
Any manipulation of data, or interraction with subreports should occur
not before the 'Format (report section) - Print (report section)' events,
as there is no controls or data there until that time.
Sub Reports also have the same Events as their Parents, but the sub
Report is not Opened until the Format (report Section) event of the Parent
is kicked off, because no controls exist until that time, and the sub
report only exixsts within the sub report control.
Therefore, if you were to place the code ::
me.filter = me.parent.filter
in the Print (report section) event of the subform, you may find it
works.
HTH
Tony
|
|
 |