Hi All
I have a form which i am filtering to multiple combo box selections using the below code.
Dim ctl As Control, Fltr As String
Dim Nam As String, fld As String
If Me.Dirty Then Me.Dirty = False 'Save first
For Each ctl In Me.Controls
If ctl.Tag = "?" Then
Nam = ctl.Name
If Trim(Me(Nam) & "") <> "" Then
fld = Switch(Nam = "Combo51", "[CustomerName] = '", _
Nam = "Combo59", "[enquiry_type] = '", _
Nam = "Combo61", "[enquiry_status] = '", _
Nam = "Combo63", "[Territory] = '", _
Nam = "Combo65", "[username] = '")
Call Command8_Click
If Fltr <> "" Then
Fltr = Fltr & " AND (" & fld & Me(Nam) & "')"
Else
Fltr = "(" & fld & Me(Nam) & "')"
End If
End If
End If
Next
If Fltr <> "" Then
Debug.Print Fltr
Me.Filter = Fltr
Me.FilterOn = True
Else
End If
i also have a separate filter which allows filtering between dates:
Me.Form.Filter = "[openingdate] BETWEEN #" & Format(Text4, "mmm dd,yyyy") & "# AND #" & Format(Text6, "mmm dd,yyyy") & "#"
Me.Form.FilterOn = True
Me.Form.OrderByOn = True
Could anyone help as to how i can combine so that if i filter to selected dates, it does not override any previous filters?? and vice versa....
Appreciate anyones help, tried to call the commands but they override any previous filter...
THanks
Ali
I have a form which i am filtering to multiple combo box selections using the below code.
Dim ctl As Control, Fltr As String
Dim Nam As String, fld As String
If Me.Dirty Then Me.Dirty = False 'Save first
For Each ctl In Me.Controls
If ctl.Tag = "?" Then
Nam = ctl.Name
If Trim(Me(Nam) & "") <> "" Then
fld = Switch(Nam = "Combo51", "[CustomerName] = '", _
Nam = "Combo59", "[enquiry_type] = '", _
Nam = "Combo61", "[enquiry_status] = '", _
Nam = "Combo63", "[Territory] = '", _
Nam = "Combo65", "[username] = '")
Call Command8_Click
If Fltr <> "" Then
Fltr = Fltr & " AND (" & fld & Me(Nam) & "')"
Else
Fltr = "(" & fld & Me(Nam) & "')"
End If
End If
End If
Next
If Fltr <> "" Then
Debug.Print Fltr
Me.Filter = Fltr
Me.FilterOn = True
Else
End If
i also have a separate filter which allows filtering between dates:
Me.Form.Filter = "[openingdate] BETWEEN #" & Format(Text4, "mmm dd,yyyy") & "# AND #" & Format(Text6, "mmm dd,yyyy") & "#"
Me.Form.FilterOn = True
Me.Form.OrderByOn = True
Could anyone help as to how i can combine so that if i filter to selected dates, it does not override any previous filters?? and vice versa....
Appreciate anyones help, tried to call the commands but they override any previous filter...
THanks
Ali