I have read loads of the threads on this subject but can find no solution to my particular problem.
I have a report rptJobHours that contains a subreport rptExpenseItems.
I wish to update, on the activate event of the main report, the recordsource of the subreport dependant on the values of 2 text boxes on the main report (FromDate and ToDate)
Here is the code of the function
Private Sub Report_Activate()
Dim varOpenArgs As Variant
If (Not IsNull(Me.OpenArgs)) Then
varOpenArgs = Split(Me.OpenArgs, ";;")
Me.FromDate = Format(varOpenArgs(0), "Short Date")
Me.ToDate = Format(varOpenArgs(1), "Short Date")
Dim frmSubReport As New Report
Set frmSubReport = Reports!rptJobHours!rptExpenseItems.Form
frmSubReport.RecordSource = "SELECT * FROM tblExpenseItems INNER JOIN tblExpenses " & _
"ON tblExpenseItems.claimNumber = tblExpenses.claimNumber " & _
"WHERE (((tblExpenseItems.jobNumber)=[Reports]![rptJobHours].[jobNumber]) AND " & _
"((tblExpenseItems.date>" & Me.FromDate & ") AND " & _
"(tblExpenseItems.date>" & Me.ToDate & "));"
frmSubReport.Requery
End If
End Sub
The line I get the Run-Time Error 2467 on is:
Set frmSubReport = Reports!rptJobHours!rptExpenseItems.Form
which I think is perculiar as the subreport is opened and does exist.
If anyone can shed any light it would be much appreciated.
Gavin
I have a report rptJobHours that contains a subreport rptExpenseItems.
I wish to update, on the activate event of the main report, the recordsource of the subreport dependant on the values of 2 text boxes on the main report (FromDate and ToDate)
Here is the code of the function
Private Sub Report_Activate()
Dim varOpenArgs As Variant
If (Not IsNull(Me.OpenArgs)) Then
varOpenArgs = Split(Me.OpenArgs, ";;")
Me.FromDate = Format(varOpenArgs(0), "Short Date")
Me.ToDate = Format(varOpenArgs(1), "Short Date")
Dim frmSubReport As New Report
Set frmSubReport = Reports!rptJobHours!rptExpenseItems.Form
frmSubReport.RecordSource = "SELECT * FROM tblExpenseItems INNER JOIN tblExpenses " & _
"ON tblExpenseItems.claimNumber = tblExpenses.claimNumber " & _
"WHERE (((tblExpenseItems.jobNumber)=[Reports]![rptJobHours].[jobNumber]) AND " & _
"((tblExpenseItems.date>" & Me.FromDate & ") AND " & _
"(tblExpenseItems.date>" & Me.ToDate & "));"
frmSubReport.Requery
End If
End Sub
The line I get the Run-Time Error 2467 on is:
Set frmSubReport = Reports!rptJobHours!rptExpenseItems.Form
which I think is perculiar as the subreport is opened and does exist.
If anyone can shed any light it would be much appreciated.
Gavin