J
jonathan
Hi, i am trying to change the recordsource of a subforms datasheet based on
whether a tick box on the main form is ticked or not.
This is my error message: invalid reference to the property form/report.
My forms are:
Main form: job_no subform
Subform: Tasks
subforms Datasheet: frmGroupTasksSubform
Thanks in advance.
Dim frm1 As Form
Dim ctl1 As Control
Dim ctl3 As Control
Dim strNaRecords As String
Dim strAllRecords As String
strNaRecords = "qryGroupTasksNA"
strAllRecords = "qryGroupTasksALL"
Set frm1 = Forms("job_no subform")
Set ctl1 = frm1.tasks
Set ctl3 = ctl1.Form.frmGroupTasksSubform
If Me.HideNASubTasks = True Then
ctl3.Form.RecordSource = strNaRecords
Else
ctl3.Form.RecordSource = strAllRecords
ctl3.Form.Requery
'Clean up objects
Set ctl1 = Nothing
Set ctl3 = Nothing
Set frm1 = Nothing
End If
whether a tick box on the main form is ticked or not.
This is my error message: invalid reference to the property form/report.
My forms are:
Main form: job_no subform
Subform: Tasks
subforms Datasheet: frmGroupTasksSubform
Thanks in advance.
Dim frm1 As Form
Dim ctl1 As Control
Dim ctl3 As Control
Dim strNaRecords As String
Dim strAllRecords As String
strNaRecords = "qryGroupTasksNA"
strAllRecords = "qryGroupTasksALL"
Set frm1 = Forms("job_no subform")
Set ctl1 = frm1.tasks
Set ctl3 = ctl1.Form.frmGroupTasksSubform
If Me.HideNASubTasks = True Then
ctl3.Form.RecordSource = strNaRecords
Else
ctl3.Form.RecordSource = strAllRecords
ctl3.Form.Requery
'Clean up objects
Set ctl1 = Nothing
Set ctl3 = Nothing
Set frm1 = Nothing
End If