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):
The cboYear has afterupdate with code:
So I need to add one more combobox cboCodeObject to filter with 2 criteria. Someting llike that:
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;
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
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