A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Setting Up & Running Reports
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

How do I determine what subreport control a subreport resides in?



 
 
Thread Tools Display Modes
  #1  
Old August 11th, 2007, 05:24 AM posted to microsoft.public.access.reports
Nyx37
external usenet poster
 
Posts: 11
Default How do I determine what subreport control a subreport resides in?

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.
  #2  
Old August 11th, 2007, 11:52 AM posted to microsoft.public.access.reports
Rick Brandt
external usenet poster
 
Posts: 4,354
Default How do I determine what subreport control a subreport resides in?

Nyx37 wrote:
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.


Can you not implement the differing filters by using different
MasterLink/ChildLink property settings on the subreport control? Then the inner
report would not need to know the container.

Otherwise if there is a way to determine which control is hosting the report I
cannot think of it.

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com


  #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.



  #4  
Old August 12th, 2007, 12:08 AM posted to microsoft.public.access.reports
Nyx37
external usenet poster
 
Posts: 11
Default How do I determine what subreport control a subreport resides

I got figured out. your code din't work but it helped me.
I placed a public varable named bytSrt in the master report and in the
subreport's open event, I incremented it.

"Douglas J. Steele" wrote:

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.




  #5  
Old August 12th, 2007, 12:31 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

Glad you worked it out, but my code does work.

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


"Nyx37" wrote in message
...
I got figured out. your code din't work but it helped me.
I placed a public varable named bytSrt in the master report and in the
subreport's open event, I incremented it.

"Douglas J. Steele" wrote:

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.






 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 06:00 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.