I've created a search form which works quite well. A user selects a value from a combo box and then hits the search button (cmdSearch) and the form is filtered using the Click event.

I would like to remove the search button and make it so that the form is automatically filtered as soon as a user selects a value from one of the combo boxes. I believe this would be in the AfterUpdate event of each combo box. If that is the case, I am not sure how to break up the code into several different combo boxes. I appreciate any help I can get.
Code:
Dim startStr As StringDim strFilter As String
If Not IsNullOrEmpty(Me.cboSearchLastName) Then
startStr = IIf(strFilter = "", "", " AND ")
strFilter = strFilter & startStr & "(tblBuilding.BuildingPK IN (" _
& " SELECT tblFacilityMgr.BuildingFK " _
& " FROM tblCustomer INNER JOIN tblFacilityMgr ON tblCustomer.CustomerPK = tblFacilityMgr.CustomerFK " _
& " WHERE tblCustomer.LastName ='" & Me.cboSearchLastName & "') OR "
strFilter = strFilter & "tblRooms.RoomsPK IN (" _
& " SELECT tblRoomsPOC.RoomsFK " _
& " FROM tblCustomer INNER JOIN tblRoomsPOC ON tblCustomer.CustomerPK = tblRoomsPOC.CustomerFK " _
& " WHERE tblCustomer.LastName ='" & Me.cboSearchLastName & "'))"
End If
If Not IsNullOrEmpty(Me.cboSearchFirstName) Then
startStr = IIf(strFilter = "", "", " AND ")
strFilter = strFilter & startStr & "(tblBuilding.BuildingPK IN (" _
& " SELECT tblFacilityMgr.BuildingFK " _
& " FROM tblCustomer INNER JOIN tblFacilityMgr ON tblCustomer.CustomerPK = tblFacilityMgr.CustomerFK " _
& " WHERE tblCustomer.FirstName ='" & Me.cboSearchFirstName & "') OR "
strFilter = strFilter & "tblRooms.RoomsPK IN (" _
& " SELECT tblRoomsPOC.RoomsFK " _
& " FROM tblCustomer INNER JOIN tblRoomsPOC ON tblCustomer.CustomerPK = tblRoomsPOC.CustomerFK " _
& " WHERE tblCustomer.FirstName ='" & Me.cboSearchFirstName & "'))"
End If
If Not IsNullOrEmpty(Me.cboSearchOrganization) Then
startStr = IIf(strFilter = "", "", " AND ")
strFilter = strFilter & startStr & "(tblBuilding.BuildingPK IN (" _
& " SELECT tblFacilityMgr.BuildingFK " _
& " FROM tblCustomer INNER JOIN tblFacilityMgr ON tblCustomer.CustomerPK = tblFacilityMgr.CustomerFK " _
& " WHERE tblCustomer.OrganizationFK =" & Me.cboSearchOrganization & ") OR "
strFilter = strFilter & "tblRooms.RoomsPK IN (" _
& " SELECT tblRoomsPOC.RoomsFK " _
& " FROM tblCustomer INNER JOIN tblRoomsPOC ON tblCustomer.CustomerPK = tblRoomsPOC.CustomerFK " _
& " WHERE tblCustomer.OrganizationFK =" & Me.cboSearchOrganization & "))"
End If
If Not IsNullOrEmpty(Me.cboSearchShopName) Then
startStr = IIf(strFilter = "", "", " AND ")
strFilter = strFilter & startStr & "(tblBuilding.BuildingPK IN (" _
& " SELECT tblFacilityMgr.BuildingFK " _
& " FROM tblCustomer INNER JOIN tblFacilityMgr ON tblCustomer.CustomerPK = tblFacilityMgr.CustomerFK " _
& " WHERE tblCustomer.ShopNameFK =" & Me.cboSearchShopName & ") OR "
strFilter = strFilter & "tblRooms.RoomsPK IN (" _
& " SELECT tblRoomsPOC.RoomsFK " _
& " FROM tblCustomer INNER JOIN tblRoomsPOC ON tblCustomer.CustomerPK = tblRoomsPOC.CustomerFK " _
& " WHERE tblCustomer.ShopNameFK =" & Me.cboSearchShopName & "))"
End If
If Not IsNullOrEmpty(Me.cboSearchOfficeSym) Then
startStr = IIf(strFilter = "", "", " AND ")
strFilter = strFilter & startStr & "(tblBuilding.BuildingPK IN (" _
& " SELECT tblFacilityMgr.BuildingFK " _
& " FROM tblCustomer INNER JOIN tblFacilityMgr ON tblCustomer.CustomerPK = tblFacilityMgr.CustomerFK " _
& " WHERE tblCustomer.OfficeSymFK =" & Me.cboSearchOfficeSym & ") OR "
strFilter = strFilter & "tblRooms.RoomsPK IN (" _
& " SELECT tblRoomsPOC.RoomsFK " _
& " FROM tblCustomer INNER JOIN tblRoomsPOC ON tblCustomer.CustomerPK = tblRoomsPOC.CustomerFK " _
& " WHERE tblCustomer.OfficeSymFK =" & Me.cboSearchOfficeSym & "))"
End If
If Not IsNullOrEmpty(Me.cboSearchBuildingName) Then
startStr = IIf(strFilter = "", "", " AND ")
strFilter = strFilter & startStr & "[BuildingPK] =" & Me.cboSearchBuildingName
End If
If Not IsNullOrEmpty(Me.cboSearchRoomName) Then
startStr = IIf(strFilter = "", "", " AND ")
strFilter = strFilter & startStr & "[RoomsPK] =" & Me.cboSearchRoomName
End If
If Not IsNullOrEmpty(Me.cboSearchEquipmentName) Then
startStr = IIf(strFilter = "", "", " AND ")
strFilter = strFilter & startStr & "tblRooms.RoomsPK IN (" _
& " SELECT tblCabinet.RoomsFK " _
& " FROM tblCabinet INNER JOIN tblEquipment ON tblCabinet.CabinetPK = tblEquipment.CabinetFK " _
& " WHERE tblEquipment.EquipmentName ='" & Me.cboSearchEquipmentName & "') "
End If
If Not IsNullOrEmpty(Me.cboSearchSerialNum) Then
startStr = IIf(strFilter = "", "", " AND ")
strFilter = strFilter & startStr & "tblRooms.RoomsPK IN (" _
& " SELECT tblCabinet.RoomsFK " _
& " FROM tblCabinet INNER JOIN tblEquipment ON tblCabinet.CabinetPK = tblEquipment.CabinetFK " _
& " WHERE tblEquipment.SerialNum ='" & Me.cboSearchSerialNum & "') "
End If
If Not IsNullOrEmpty(Me.cboSearchEquipmentIP) Then
startStr = IIf(strFilter = "", "", " AND ")
strFilter = strFilter & startStr & "tblRooms.RoomsPK IN (" _
& " SELECT tblCabinet.RoomsFK " _
& " FROM tblCabinet INNER JOIN tblEquipment ON tblCabinet.CabinetPK = tblEquipment.CabinetFK " _
& " WHERE tblEquipment.EquipmentIP ='" & Me.cboSearchEquipmentIP & "') "
End If
Call MsgBox(strFilter, vbOKOnly, "Debug")
If DCount("*", "qryFrmMainRooms", strFilter) = 0 Then
MsgBox "No corresponding records to your search criteria." & vbCrLf & vbCrLf
Call cmdReset_Click
End If
Me.Filter = strFilter
Me.FilterOn = True