Accessing sub report controls.

  • Thread starter Thread starter box2003
  • Start date Start date
B

box2003

I have been trying to access a control on a sub report using the following
info, though it does not seem to be working. The sub report control is
txtEmployeeSeniority. All I get in the control on my Main Report control
that I am trying to populate, txtServiceYears, is #Name#. I have included
the below information about both reports.

Main Report: rptCompanyData
Main Report Control: txtServiceYears
Sub Report: rptEmployeeInfo_sub
Sub Report Control: txtEmployeeSeniority

Reports!rptCompanyData!Report!rptEmployeeInfo_sub!txtEmployeeSeniority

What am I doing wrong?

Thanks.
 
Try:
=[rptEmployeeInfo_Sub].[Report].[txtEmployeeSeniority]

where:
rptEmployeeInfo_Sub is the name of the subreport control,
.Report gets you to the report in that control, and
txtEmployeeSeniority is the text box in the subreport.

That should work unless the subreport has no data. In that case, referring
to the nonexistent control in the subreport generates #Error. You can avoid
that by testing the HasData property of the report in the subreport control,
i.e.:

=IIf([rptEmployeeInfo_Sub].[Report].[HasData],
[rptEmployeeInfo_Sub].[Report].[txtEmployeeSeniority], Null)
 
Back
Top