Add second filter criteria (1 Viewer)

tihmir

Registered User.
Local time
Yesterday, 21:01
Joined
May 1, 2018
Messages
257
Hello, everyone. I need some help.
I have a form with name fmObjectsWithoutInspections. Thah form has a subform with name fmObjectsWithoutInspections_sub.
On the main form I have combobox cboYear to filter the subform with the query (qry_ObjectsWithoutInspections):
Code:
SELECT T1.ObjectID, T1.CodeObject, T1.City, T1.Street, Т2.DateStarted, T2.ObjectID
FROM tblObjects AS T1 LEFT JOIN (SELECT * FROM tblInspections) AS T2 ON T1.ObjectID = T2.ObjectID
GROUP BY T1.ObjectID, T1.City, T2.DateStarted, T2.ObjectID
HAVING (((T1.CodeObject) Not In (63,70,71,74,77,78,79,80,81,82,83,84,85,86,87,88,89,90)))
ORDER BY T1.CodeObject;
The cboYear has afterupdate with code:
Code:
    If cboYear > Year(Now()) Then
        MsgBox "Some message.", vbInformation, "Atention!"
        cboYear = Null
        cboYear.SetFocus
        Cancel = True
        Me!fmObjectsWithoutInspections_sub.Form.RecordSource = "qry_ObjectsWithoutInspections"
        Exit Sub
    Else
        sql = "SELECT T1.*, T2.DateStarted FROM tblObjects AS T1 LEFT JOIN" _
        & "(SELECT * FROM tblInspections WHERE Year(Year)=" & Me.cboYear & ") AS T2 ON T1.ObjectID = T2.ObjectID WHERE ((T2.ObjectID) Is Null)"
            
        Me.fmObjectsWithoutInspections_sub.Form.RecordSource = sql
        Me.fmObjectsWithoutInspections_sub.Form.Requery
    End If
So I need to add one more combobox cboCodeObject to filter with 2 criteria. Someting llike that:
Code:
    So I need to add one more combobox cboCodeObject to filter with 2 criteria. Someting llike that:
    
       If Nz(Me.cboYear, "") = "" Then
        MsgBox "Please first chose year ", vbExclamation, "No year group selected"
        Me.cboCodeObject = ""
    Else
    
 
    End If
 

MarkK

bit cruncher
Local time
Yesterday, 21:01
Joined
Mar 17, 2004
Messages
8,181
It's not clear to me what you are asking for help with.
 

Users who are viewing this thread

Top Bottom