I have been trying to use a pass through query as the record source for a sub report, but apparently it is not allowed without some work around.
I have been researching online and I came across this article where I can set the record source of the sub form in the main forms on load event:
http://support.microsoft.com/kb/112746
This error will occur in Microsoft Access 7.0 and 97 if you have LinkMasterFields and LinkChildFields defined for the subform or subreport. In order to use an SQL pass-through query as a subform's record source in Microsoft Access 1.x and 2.0, you have to dynamically set the subform's RecordSource property in the main form's Load event. The following is an example of an OnLoad property event procedure in the main form MainForm that dynamically sets the RecordSource property in the subform SPTSubForm:
Sub MainForm_OnLoad Me!SPTSubForm.Form.RecordSource = "[<Name of SQL pass-through query>]" End SubHere is my code. I keep getting a run time error 2467 that the expression you entered refers to an object that is closed or doesn't exist.I have confirmed that the pass through query exists and does work. If I bind it directly to the sub reports on open event and open it on its own it does work.The main report is also bound to a pass through query. The main report has all the summary totals, but the subreport is needed for the detailed data. I can't think of how I could join it together in one query to have it all return and just use the grouping in Access.
Private Sub Report_Load()
Me!AMI10SubReport.Report.RecordSource = "[sp_GenerateVarianceReportData_AMI10]"
End Sub
I have been researching online and I came across this article where I can set the record source of the sub form in the main forms on load event:
http://support.microsoft.com/kb/112746
This error will occur in Microsoft Access 7.0 and 97 if you have LinkMasterFields and LinkChildFields defined for the subform or subreport. In order to use an SQL pass-through query as a subform's record source in Microsoft Access 1.x and 2.0, you have to dynamically set the subform's RecordSource property in the main form's Load event. The following is an example of an OnLoad property event procedure in the main form MainForm that dynamically sets the RecordSource property in the subform SPTSubForm:
Sub MainForm_OnLoad Me!SPTSubForm.Form.RecordSource = "[<Name of SQL pass-through query>]" End SubHere is my code. I keep getting a run time error 2467 that the expression you entered refers to an object that is closed or doesn't exist.I have confirmed that the pass through query exists and does work. If I bind it directly to the sub reports on open event and open it on its own it does work.The main report is also bound to a pass through query. The main report has all the summary totals, but the subreport is needed for the detailed data. I can't think of how I could join it together in one query to have it all return and just use the grouping in Access.
Private Sub Report_Load()
Me!AMI10SubReport.Report.RecordSource = "[sp_GenerateVarianceReportData_AMI10]"
End Sub