Hi im just starting to explore VB 6 and my project is a database with multiple filtering function using checkboxes. I was able to filter the data with multiple checkboxes but how will I make my code shorter since I have like 15 checkboxes. My code below will only work for a single combination of the checkboxes. Thank you in advance guys.
If check1.Value = 1 Then
If check2.Value = 1 Then
If check3.Value = 1 Then
If check4.Value = 1 Then
If check5.Value = 1 Then
s = -1
Set rs = New ADODB.Recordset
rs.CursorLocation = adUseClient
rs.Open "Select * from table1 where value1 and value2 and value3 and value4 and value5 like '" & s & "%'", cn, adOpenKeyset, adLockOptimistic, adCmdText
Set DataGrid1.DataSource = rs
Set rs = Nothing
End If
End If
End If
End If
End If
If check1.Value = 1 Then
If check2.Value = 1 Then
If check3.Value = 1 Then
If check4.Value = 1 Then
If check5.Value = 1 Then
s = -1
Set rs = New ADODB.Recordset
rs.CursorLocation = adUseClient
rs.Open "Select * from table1 where value1 and value2 and value3 and value4 and value5 like '" & s & "%'", cn, adOpenKeyset, adLockOptimistic, adCmdText
Set DataGrid1.DataSource = rs
Set rs = Nothing
End If
End If
End If
End If
End If