Code for the query def:
Code:
Set db = CurrentDb
If Not QueryExixts("tbltesting") Then
Set qdf = db.CreateQueryDef("tbltesting")
Else
Set qdf = db.QueryDefs("tbltesting")
End If
If Not IsNull(Me.cbomagazine1) Then
strMag = "M" & Me.cbomagazine1 & "='" & Me.cbomagazine1 & "'"
End If
If Not IsNull(Me.cbomagazine2) Then
strMag = strMag & IIf(strMag <> "", " OR ", "") & "M" & Me.cbomagazine2 & "='" & Me.cbomagazine2 & "'"
End If
qdf.SQL = "SELECT qryall.* FROM qryall " & _
"WHERE " & strMag & _
IIf(Not IsNull(Me.cbomagazine1) Or Not IsNull(Me.cbomagazine2), " ORDER BY ", "") & _
IIf(Not IsNull(Me.cbomagazine1), "M" & Me.cbomagazine1, "") & _
IIf(Not IsNull(Me.cbomagazine1) And Not IsNull(Me.cbomagazine2), ", ", "") & _
IIf(Not IsNull(Me.cbomagazine2), "M" & Me.cbomagazine2, "") & ";"
Code for the form search:
Code:
Me.qryall_subform.Requery
Me.qryall_subform.Form.FilterOn = False
Me.qryall_subform.Form.Filter = "[M" & Me.cbomagazine1 & "]='" & Me.cbomagazine1 & "' OR [M" & Me.cbomagazine2 & "]='" & Me.cbomagazine2 & "'"
Me.qryall_subform.Form.FilterOn = True