Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing Control Source of Subreport on open of main report

Status
Not open for further replies.

Farzam

MIS
Nov 5, 2006
19
LU
Dear All,
Iam using MS Access Project ADP as Front back SQL SERVER.
I have a main report (Matrix_Report45)
having some 30 subreports,
I want to change the control source of all subreports based on value choosen from a form.

I put a simple code on behind the button on the from ... to open the Main Report dilevering a value for the choosen Year,
based on the year all the Record Sources in subreports shoud be updated before the main report print previews...
I put the bunch of codes in both on Open of the main report and OnFormat but i get this runtime error,

Runtime Error 2455, You entered an expression that has an invalid reference to the property From/Report...

Thanks
 
Code On Open of Main Report
though i used different syntax references like
Report_Matrix_Report45.MxYear1.Report.RecordSource
Reports![Matrix_Report45]![MxYear1].Report.RecordSource
Reports![Matrix_Report45]![MxYear1]!Report.RecordSource
etc......but gettting that famouse error
'--------------------------------------'
'Codes for Matrix Report Startup
'---------------------------------------'
'--Contracts----Year1'

If Form_MxReportCall.StartYear.Value = "2007" Then

Report_Matrix_Report45.MxYear1.Report.RecordSource = "2007"
Report_Matrix_Report45.MxCLyear1.Report.RecordSource = "Closing2007"
Report_Matrix_Report45.MxFCyear1.Report.RecordSource = "MxFC2007"
Report_Matrix_Report45.MxPMYear1.Report.RecordSource = "MxPM2007"
'---Year2
Report_Matrix_Report45.MxYear2.Report.RecordSource = "2008"
Report_Matrix_Report45.MXCLYear2.Report.RecordSource = "Closing2008"
Report_Matrix_Report45.MxFCYear2.Report.RecordSource = "MxFC2008"
Report_Matrix_Report45.MxPMYear2.Report.RecordSource = "MxPM2008"
'----------------------------------------------------
'---Year3
Report_Matrix_Report45.MxYear3.Report.RecordSource = "2009"
Report_Matrix_Report45.MxCLYear3.Report.RecordSource = "Closing2009"
Report_Matrix_Report45.MxFCyear3.Report.RecordSource = "MxFC2009"
Report_Matrix_Report45.MxPMYear3.Report.RecordSource = "MxPM2009"
'----------------------------------------------------

'---Year4
Report_Matrix_Report45.MxYear4.Report.RecordSource = "2010"
Report_Matrix_Report45.MxCLYear4.Report.RecordSource = "Closing2010"
Report_Matrix_Report45.MxFCyear4.Report.RecordSource = "MxFC2010"
Report_Matrix_Report45.MxPMYear4.Report.RecordSource = "MxPM2010"
'----------------------------------------------------

'---Year5
Report_Matrix_Report45.MxYear5.Report.RecordSource = "2011"
Report_Matrix_Report45.MxCLyear5.Report.RecordSource = "Closing2011"
Report_Matrix_Report45.MxFCyear5.Report.RecordSource = "MxFC2011"
Report_Matrix_Report45.MxPMYear5.Report.RecordSource = "MxPM2011"
'----------------------------------------------------
'---Year6
Report_Matrix_Report45.MxYear6.Report.RecordSource = "2012"
Report_Matrix_Report45.MxCLyear6.Report.RecordSource = "Closing2012"
Report_Matrix_Report45.MxFCyear6.Report.RecordSource = "MxFC2012"
Report_Matrix_Report45.MxPMYear6.Report.RecordSource = "MxPM2012"
'----------------------------------------------------
'---Year7
Report_Matrix_Report45.MxYear7.Report.RecordSource = "2013"
Report_Matrix_Report45.MxCLYear7.Report.RecordSource = "Closing2013"
Report_Matrix_Report45.MxFCyear7.Report.RecordSource = "MxFC2013"
Report_Matrix_Report45.MxPMYear7.Report.RecordSource = "MxPM2013"
'----------------------------------------------------
'---Year8
Report_Matrix_Report45.MxYear8.Report.RecordSource = "2014"
Report_Matrix_Report45.MxCLYear8.Report.RecordSource = "Closing2014"
Report_Matrix_Report45.MxFCyear8.Report.RecordSource = "MxFC2014"
Report_Matrix_Report45.MxPMYear8.Report.RecordSource = "MxPM2014"
'----------------------------------------------------
'---Year9
Report_Matrix_Report45.MxYear9.Report.RecordSource = "2015"
Report_Matrix_Report45.MxCLYear9.Report.RecordSource = "Closing2015"
Report_Matrix_Report45.MxFCYear9.Report.RecordSource = "MxFC2015"
Report_Matrix_Report45.MxPMYear9.Report.RecordSource = "MxPM2015"
'----------------------------------------------------
End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top