View Single Post
  #3  
Old August 11th, 2007, 07:35 PM posted to microsoft.public.access.reports
Douglas J. Steele
external usenet poster
 
Posts: 9,313
Default How do I determine what subreport control a subreport resides in?

Try this.

Set a global variable in your application, say glngSubreport. (Note that it
must be declared in a standalone module, so that it's accessible from both
the report and subreport)

In the report's Open event, assign the variable a value:

Private Sub Report_Open(Cancel As Integer)

glngSubreport = 1

End Sub

Add an unbound text box (temporarily) to your subreport. Let's assume you
named the control txtWhatSubreport. Put the following code in its Open
event:

Private Sub Report_Open(Cancel As Integer)

Select Case glngSubReportCount
Case 1 To 2
Me.txtWhatSubreport.ControlSource = "=" & glngSubreport
End Select

glngSubreport = glngSubreport + 1

End Sub

When you run the report, the two subreports will now have either 1 or 2 in
the text box you added.

That will not change unless you delete and readd the subreport to the form.

Note that the reason for limiting the code in the subreport's Open event to
only values of 1 or 2 is that the subreport's Open event fires for each
page, and you cannot change the ControlSource property of a report once it's
started to populate.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"Nyx37" wrote in message
news
I have a report with two subreports that are the same child report. I want
to be able to tell, within a subreports open event, which subreport
control
it resides in. (i.e. if it's control 1 or 2) I need to do this so I can
reuse the same report in each subreport. Only the filter properties are
differnt.