Attachment 90385
I want to know if any1 have an idea to filter my datagrid with this checkboxes
]
I want to know if any1 have an idea to filter my datagrid with this checkboxes
Code:
Sub listevents()
With Form3
If .Text1.Text <> "" Then namefilter = "%" + Trim(.Text1.Text) + "%" Else namefilter = ""
lifefilter = .Text3.Text
For i = 0 To .List1.ListCount - 1
.List1.ListIndex = i
If .List1.Selected(i) = True Then
If abilitiesfilter = "" Then abilitiesfilter = "%" + .List1.Text + "%" Else abilitiesfilter = abilitiesfilter + "' Or Abilities LIKE '" + "%" + .List1.Text + "%"
End If
Next i
For i = 0 To .List2.ListCount - 1
.List2.ListIndex = i
If .List2.Selected(i) = False Then
If teamfilter = "" Then teamfilter = "%" + .List2.Text + "%" Else teamfilter = teamfilter + "' And Team NOT LIKE '" + "%" + .List2.Text + "%"
End If
Next i
For i = 0 To .List3.ListCount - 1
.List3.ListIndex = i
If .List3.Selected(i) = False Then
If setfilter = "" Then setfilter = .List3.Text Else setfilter = setfilter + "', '" + .List3.Text
End If
Next i
' .Text11.Text = teamfilter
' .Text12.Text = abilitiesfilter
oRs.Close
'01 STAN X----
If setfilter <> "" And teamfilter = "" And abilitiesfilter = "" And namefilter = "" And lifefilter = 0 Then
oRs.Open "select * from heroclixmain where Set Not IN ('" & setfilter & "') ORDER BY Code", adoConn, adOpenStatic, adLockOptimistic
'02 STAN -X---
ElseIf setfilter = "" And teamfilter <> "" And abilitiesfilter = "" And namefilter = "" And lifefilter = 0 Then
oRs.Open "select * from heroclixmain where Team NOT LIKE '" & teamfilter & "' ORDER BY Code", adoConn, adOpenStatic, adLockOptimistic
'03 STAN --X--
ElseIf setfilter = "" And teamfilter = "" And abilitiesfilter <> "" And namefilter = "" And lifefilter = 0 Then
oRs.Open "select * from heroclixmain where Abilities LIKE '" & abilitiesfilter & "' ORDER BY Code", adoConn, adOpenStatic, adLockOptimistic
'04 STAN ---X-
ElseIf setfilter = "" And teamfilter = "" And abilitiesfilter = "" And namefilter <> "" And lifefilter = 0 Then
oRs.Open "select * from heroclixmain where Name LIKE '" & namefilter & "' ORDER BY Code", adoConn, adOpenStatic, adLockOptimistic
'05 STAN XX---
ElseIf setfilter <> "" And teamfilter <> "" And abilitiesfilter = "" And namefilter = "" And lifefilter = 0 Then
oRs.Open "select * from heroclixmain where Set Not IN ('" & setfilter & "') AND Team not LIKE '" & teamfilter & "' ORDER BY Code", adoConn, adOpenStatic, adLockOptimistic
'06 STAN -XX--
ElseIf setfilter = "" And teamfilter <> "" And abilitiesfilter <> "" And namefilter = "" And lifefilter = 0 Then
oRs.Open "select * from heroclixmain where Team not LIKE '" & teamfilter & "' AND Abilities LIKE '" & abilitiesfilter & "' ORDER BY Code", adoConn, adOpenStatic, adLockOptimistic
'07 STAN --XX-
ElseIf setfilter = "" And teamfilter = "" And abilitiesfilter <> "" And namefilter <> "" And lifefilter = 0 Then
oRs.Open "select * from heroclixmain where Abilities LIKE '" & abilitiesfilter & "' AND Name LIKE '" & namefilter & "' ORDER BY Code", adoConn, adOpenStatic, adLockOptimistic
'08 STAN X--X-
ElseIf setfilter <> "" And teamfilter = "" And abilitiesfilter = "" And namefilter <> "" And lifefilter = 0 Then
oRs.Open "select * from heroclixmain where Set Not IN ('" & setfilter & "') AND Name LIKE '" & namefilter & "' ORDER BY Code", adoConn, adOpenStatic, adLockOptimistic
'09 STAN X-X--
ElseIf setfilter <> "" And teamfilter = "" And abilitiesfilter <> "" And namefilter = "" And lifefilter = 0 Then
oRs.Open "select * from heroclixmain where Set Not IN ('" & setfilter & "') AND Abilities LIKE '" & abilitiesfilter & "' ORDER BY Code", adoConn, adOpenStatic, adLockOptimistic
'10 STAN -X-X-
ElseIf setfilter = "" And teamfilter <> "" And abilitiesfilter = "" And namefilter <> "" And lifefilter = 0 Then
oRs.Open "select * from heroclixmain where Team not LIKE '" & teamfilter & "' AND Name LIKE '" & namefilter & "' ORDER BY Code", adoConn, adOpenStatic, adLockOptimistic
'11 STAN XXX--
ElseIf setfilter <> "" And teamfilter <> "" And abilitiesfilter <> "" And namefilter = "" And lifefilter = 0 Then
oRs.Open "select * from heroclixmain where Set Not IN ('" & setfilter & "') AND Team not LIKE '" & teamfilter & "' AND Abilities LIKE '" & abilitiesfilter & "' ORDER BY Code", adoConn, adOpenStatic, adLockOptimistic
'12 STAN -XXX-
ElseIf setfilter = "" And teamfilter <> "" And abilitiesfilter <> "" And namefilter <> "" And lifefilter = 0 Then
oRs.Open "select * from heroclixmain where Team not LIKE '" & teamfilter & "' AND Abilities LIKE '" & abilitiesfilter & "' AND Name LIKE '" & namefilter & "' ORDER BY Code", adoConn, adOpenStatic, adLockOptimistic
'13 STAN X-XX-
ElseIf setfilter <> "" And teamfilter = "" And abilitiesfilter <> "" And namefilter <> "" And lifefilter = 0 Then
oRs.Open "select * from heroclixmain where Set Not IN ('" & setfilter & "') AND Abilities LIKE '" & abilitiesfilter & "' AND Name LIKE '" & namefilter & "' ORDER BY Code", adoConn, adOpenStatic, adLockOptimistic
'14 STAN XX-X-
ElseIf setfilter <> "" And teamfilter <> "" And abilitiesfilter = "" And namefilter <> "" And lifefilter = 0 Then
oRs.Open "select * from heroclixmain where Set Not IN ('" & setfilter & "') AND Team not LIKE '" & teamfilter & "' AND Name LIKE '" & namefilter & "' ORDER BY Code", adoConn, adOpenStatic, adLockOptimistic
'15 STAN XXXX-
ElseIf setfilter <> "" And teamfilter <> "" And abilitiesfilter <> "" And namefilter <> "" And lifefilter = 0 Then
oRs.Open "select * from heroclixmain where Set Not IN ('" & setfilter & "') AND Team not LIKE '" & teamfilter & "' AND Abilities LIKE '" & abilitiesfilter & "' AND Name LIKE '" & namefilter & "' ORDER BY Code", adoConn, adOpenStatic, adLockOptimistic
'16 STAN -----
ElseIf setfilter = "" And teamfilter = "" And abilitiesfilter = "" And namefilter = "" And lifefilter = 0 Then
oRs.Open "select * from heroclixmain ORDER BY Code", adoConn, adOpenStatic, adLockOptimistic
'17 STAN ----X
ElseIf setfilter = "" And teamfilter = "" And abilitiesfilter = "" And namefilter = "" And lifefilter <> 0 Then
oRs.Open "select * from heroclixmain where Points = " & lifefilter & " ORDER BY Code", adoConn, adOpenStatic, adLockOptimistic
'18 STAN ---XX
ElseIf setfilter = "" And teamfilter = "" And abilitiesfilter = "" And namefilter <> "" And lifefilter <> 0 Then
oRs.Open "select * from heroclixmain where Name LIKE '" & namefilter & "' AND Points = " & lifefilter & " ORDER BY Code", adoConn, adOpenStatic, adLockOptimistic
'19 STAN X---X
ElseIf setfilter <> "" And teamfilter = "" And abilitiesfilter = "" And namefilter = "" And lifefilter <> 0 Then
oRs.Open "select * from heroclixmain where Set Not IN ('" & setfilter & "') AND Points = " & lifefilter & " ORDER BY Code", adoConn, adOpenStatic, adLockOptimistic
'20 STAN -X--X
ElseIf setfilter = "" And teamfilter <> "" And abilitiesfilter = "" And namefilter = "" And lifefilter <> 0 Then
oRs.Open "select * from heroclixmain where Team not LIKE '" & teamfilter & "' AND Points = " & lifefilter & " ORDER BY Code", adoConn, adOpenStatic, adLockOptimistic
'21 STAN --X-X
ElseIf setfilter = "" And teamfilter = "" And abilitiesfilter <> "" And namefilter = "" And lifefilter <> 0 Then
oRs.Open "select * from heroclixmain where Abilities LIKE '" & abilitiesfilter & "' AND Points = " & lifefilter & " ORDER BY Code", adoConn, adOpenStatic, adLockOptimistic
'23 STAN XX--X
ElseIf setfilter <> "" And teamfilter <> "" And abilitiesfilter = "" And namefilter = "" And lifefilter <> 0 Then
oRs.Open "select * from heroclixmain where Set Not IN ('" & setfilter & "') AND Team not LIKE '" & teamfilter & "' AND Points = " & lifefilter & " ORDER BY Code", adoConn, adOpenStatic, adLockOptimistic
'24 STAN -XX-X
ElseIf setfilter = "" And teamfilter <> "" And abilitiesfilter <> "" And namefilter = "" And lifefilter <> 0 Then
oRs.Open "select * from heroclixmain where Team not LIKE '" & teamfilter & "' AND Abilities LIKE '" & abilitiesfilter & "' AND Points = " & lifefilter & " ORDER BY Code", adoConn, adOpenStatic, adLockOptimistic
'25 STAN --XXX
ElseIf setfilter = "" And teamfilter = "" And abilitiesfilter <> "" And namefilter <> "" And lifefilter <> 0 Then
oRs.Open "select * from heroclixmain where Abilities LIKE '" & abilitiesfilter & "' AND Name LIKE '" & namefilter & "' AND Points = " & lifefilter & " ORDER BY Code", adoConn, adOpenStatic, adLockOptimistic
'26 STAN XXXXX
ElseIf setfilter <> "" And teamfilter <> "" And abilitiesfilter <> "" And namefilter <> "" And lifefilter <> 0 Then
oRs.Open "select * from heroclixmain where Set Not IN ('" & setfilter & "') AND Team not LIKE '" & teamfilter & "' AND Abilities LIKE '" & abilitiesfilter & "' AND Name LIKE '" & namefilter & "' AND Points = " & lifefilter & " ORDER BY Code", adoConn, adOpenStatic, adLockOptimistic
End If
Set .DataGrid1.DataSource = oRs
End With
End Sub