I have an unbound subform on a bound form. I am trying to set the recordsource of the subform in vba from the click event of a command button to display the records related to the value of a field on the parent form. I am getting a run time error 2467 - "The expression you entered refers to an object that is closed or doesn't exist." This error is ocurring on the line of code listed below. This seems like it should be very simple but is causing me a great deal of trouble.
Addtionaly, I cannot simply create a bound subform and link the fields as I want to group the data by multiple fields.
Private Sub Command73_Click()
Dim strSQL As String
strSQL = "SELECT FIRST([Group Code]), [Month], FIRST([Quarter]), FIRST([Year]), " & _
"SUM([Gross Sales]), SUM([CM-PY Sales]), SUM([E-Sales]), SUM([Rebateable Sales]), " & _
"SUM([Standard Calc Percent]), SUM([Growth Calc Percent]), SUM([Electronic Calc Percent]) " & _
"FROM tblHistoricSales WHERE [Group Code] = '" & Me.GROUP_CODE.Value & "' " & _
"GROUP BY [Month]"
'***The error occurs on the following line:
Me.tblHistoricalSales_subform.Form.RecordSource = strSQL