I am using the following code to filter a form, frm_ExternalAudit_View, with a subform, fr_AuditDetails. The field that I want to filter is [Status] and this is found in the subform.
Dim stDocName As String, Whereclause As String, frm As Form, sfrm As Form
Set frm = Forms!frm_ExternalAudit_View
Set sfrm = frm!frm_AuditDetails.Form
stDocName = "frm_ExternalAudit_View"
If Not IsNull(cbo_Auditor) Then
Whereclause = "[Auditor Name] = '" & cbo_Auditor & "'"
End If
If Not IsNull(cbo_Department) Then
If Whereclause <> "" Then Whereclause = Whereclause & " AND "
Whereclause = Whereclause & "[Agency] = '" & cbo_Department & "'"
End If
If Not IsNull(cbo_Agency) Then
If Whereclause <> "" Then Whereclause = Whereclause & " AND "
Whereclause = Whereclause & "[Agency] = '" & cbo_Agency & "'"
End If
If Not IsNull(cbo_SingleDate) Then
If Whereclause <> "" Then Whereclause = Whereclause & " AND "
Whereclause = Whereclause & "[Audit Date] = #" & Format(cbo_SingleDate, "mm/dd/yyyy") & "#"
End If
If Not IsNull(cbo_StartDate) Then
If Whereclause <> "" Then Whereclause = Whereclause & " AND "
Whereclause = Whereclause & "[Audit Date] >= #" & Format(cbo_StartDate, "mm/dd/yyyy") & "#"
End If
If Not IsNull(cbo_EndDate) Then
If Whereclause <> "" Then Whereclause = Whereclause & " AND "
Whereclause = Whereclause & "[Audit Date] <= #" & Format(cbo_EndDate, "mm/dd/yyyy") & "#"
End If
If Not IsNull(cbo_Status) Then
If Whereclause <> "" Then Whereclause = Whereclause & " AND "
Whereclause = Whereclause & "sfrm![Status] = '" & cbo_Status & "'"
End If
DoCmd.Close
DoCmd.OpenForm stDocName, , , Whereclause
DoCmd.Maximize
When I run the code, I get the error message "Microsoft access can't find the form 'frm_ExternalAudit_View' referred to in a macro expression or vb code." What does this mean?
Thanks.
Dim stDocName As String, Whereclause As String, frm As Form, sfrm As Form
Set frm = Forms!frm_ExternalAudit_View
Set sfrm = frm!frm_AuditDetails.Form
stDocName = "frm_ExternalAudit_View"
If Not IsNull(cbo_Auditor) Then
Whereclause = "[Auditor Name] = '" & cbo_Auditor & "'"
End If
If Not IsNull(cbo_Department) Then
If Whereclause <> "" Then Whereclause = Whereclause & " AND "
Whereclause = Whereclause & "[Agency] = '" & cbo_Department & "'"
End If
If Not IsNull(cbo_Agency) Then
If Whereclause <> "" Then Whereclause = Whereclause & " AND "
Whereclause = Whereclause & "[Agency] = '" & cbo_Agency & "'"
End If
If Not IsNull(cbo_SingleDate) Then
If Whereclause <> "" Then Whereclause = Whereclause & " AND "
Whereclause = Whereclause & "[Audit Date] = #" & Format(cbo_SingleDate, "mm/dd/yyyy") & "#"
End If
If Not IsNull(cbo_StartDate) Then
If Whereclause <> "" Then Whereclause = Whereclause & " AND "
Whereclause = Whereclause & "[Audit Date] >= #" & Format(cbo_StartDate, "mm/dd/yyyy") & "#"
End If
If Not IsNull(cbo_EndDate) Then
If Whereclause <> "" Then Whereclause = Whereclause & " AND "
Whereclause = Whereclause & "[Audit Date] <= #" & Format(cbo_EndDate, "mm/dd/yyyy") & "#"
End If
If Not IsNull(cbo_Status) Then
If Whereclause <> "" Then Whereclause = Whereclause & " AND "
Whereclause = Whereclause & "sfrm![Status] = '" & cbo_Status & "'"
End If
DoCmd.Close
DoCmd.OpenForm stDocName, , , Whereclause
DoCmd.Maximize
When I run the code, I get the error message "Microsoft access can't find the form 'frm_ExternalAudit_View' referred to in a macro expression or vb code." What does this mean?
Thanks.