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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|