I have a search form with multiple cascading combo boxes. Most combo boxes record sources are linked to a singular table field whereas I am using this code to filter results
Please Use Code Tags
My problem is that I have other combo boxes who's record sources are linked to a Union All query - whereas depending on the selection the data may be coming from [BathTypes1] or [BathTypes2] or [BathTypes3] and I am unable to figure out a working code I have tried so many variations including the following - (does not work)
Please Use Code Tags
My experience at coding is very limited and any help in the right direction is much apprecaited
Code:
Please Use Code Tags
Function SearchCriteria()
Dim CustomerType As String
Dim Task As String
Dim strCriteria As String
' Example
If Not IsNull(Me.cboBathTypes) Then ' Baths
CustomerType = CustomerType & " And ([BathTypes1] = '" & Me.cboBathTypes & "')"
End If
strCriteria = CustomerType
Task = "SELECT * FROM qry_Customer where " & strCriteria & " Order by CustomerName asc"
Me.frm_ExtProducts_Subform1.Form.RecordSource = Task
Me.frm_ExtProducts_Subform1.Form.Requery
End Function
My problem is that I have other combo boxes who's record sources are linked to a Union All query - whereas depending on the selection the data may be coming from [BathTypes1] or [BathTypes2] or [BathTypes3] and I am unable to figure out a working code I have tried so many variations including the following - (does not work)
Code:
Please Use Code Tags
If Not IsNull(Me.cboBathTypes) Then ' Baths
CustomerType = CustomerType & " And ([BathTypes1] = '" & Me.cboBathTypes & "')"
Else
CustomerType = CustomerType & " And ([BathTypes2] = '" & Me.cboBathTypes & "')"
End If
My experience at coding is very limited and any help in the right direction is much apprecaited
Last edited by a moderator: