Hello,
I have a data-table that is filled with data (is logical
). I use a search form to populate data from this table into a listbox.
At the moment I have two combo-boxes (one for the column to search in and one for the column to order on). I use a textbox (sText) to enter a search string.
In the data-table there are a few columns (15) that have the data type : Yes/No
I would like to add a few check-boxes (15) where the uses can apply a pre sort.
So when the user clicks on a checkbox all the rows are selected and with the textbox a search term can be entered to search the selection. I've got this already working with one checkbox.
Now I would like to do this with multiple check boxes, but then i becomes a problem to me....
In order to get this working (with my knowledge) I have to program every possible combination of checkbox.value = true.
Now I would like to add the checkbox "Chksubscription" with the following field-name: subscription (this is just an example for a field-name, not the real one I use). The code will be:
This is the code for two check-boxes, and I have got 15 checkboxes.
Is there a better, more efficient way?
Thanks in advance.
I have a data-table that is filled with data (is logical

At the moment I have two combo-boxes (one for the column to search in and one for the column to order on). I use a textbox (sText) to enter a search string.
In the data-table there are a few columns (15) that have the data type : Yes/No
I would like to add a few check-boxes (15) where the uses can apply a pre sort.
So when the user clicks on a checkbox all the rows are selected and with the textbox a search term can be entered to search the selection. I've got this already working with one checkbox.
Code:
If ChkMember.Value = True Then
StrSql = StrSql & "WHERE " & " [Member]=True AND " & Me.ComboCategory.Column(1) & " Like '" & "*" & sText & "*" & "*' ORDER BY " & Me.ComboCategory.Column(1) & ";"
Else
StrSql = StrSql & "WHERE " & Me.ComboCategory.Column(1) & " Like '" & "*" & sText & "*" & "*' ORDER BY " & Me.ComboFilteredBy.Column(1) & ";"
End If
In order to get this working (with my knowledge) I have to program every possible combination of checkbox.value = true.
Now I would like to add the checkbox "Chksubscription" with the following field-name: subscription (this is just an example for a field-name, not the real one I use). The code will be:
Code:
If ChkMember.Value = True and ChkSubscription.Value = True Then
'Do code
elseif ChkMember.Value = True and ChkSubscription.Value = false then
'Do code
elseif ChkMember.Value = false and ChkSubscription.Value = true then
'Do code
elseif ChkMember.Value = false and ChkSubscription.Value = false then
'Do code
end if
This is the code for two check-boxes, and I have got 15 checkboxes.
Is there a better, more efficient way?
Thanks in advance.
Last edited: