Ok, now I understand better what you are doing. The coding is easier if you
do use checkboxes rather than listboxes, so below is with multiple
checkboxes, but is written simply rather than looping as I might if there are
many checkboxes;
Private Sub MyButton_Click()
Dim strQueryFlds as String
If Me.chkCustName = -1 Then
strQueryFlds = "custname, "
End If
If Me.chkCustAddr = -1 Then
strQueryFlds = strQueryFlds & "custaddr, "
End If
If Me.chkCustNote = -1 Then
strQueryFlds = strQueryFlds & "custnote, "
End If
....
and so on for each checkbox, then at the end;
If not strQueryFlds = "" Then
strQueryFlds = "SELECT " & strQueryFlds & "FROM yourQueryNameHere"
Else
strQueryFlds = "SELECT * FROM yourQueryNameHere"
End If
Now you can do what you want with the recordset definition you have created,
eg run it or set it as the recordsource for a subform, another form or
report, or use it as a rowsource for a listbox.
You could also add " ORDER BY anyFieldNameYouLike" at the end too if want to
see it in a particular order.
Without wishing to confuse you, you can actually remove the '= -1' part from
each of the If's above, but to make it easier to understand I put them in
anyway. Basically if there is only a yes/no or true/false or -1/0 possible
value of a field or string you can omit the = True/Yes/-1 part as Access will
automatically evaluate it as looking for True unless you state otherwise.
hope this helps, and check the code compiles as it's only aircode and not
tested, make sure you leave the spaces after the commas for each line of
strQueryFlds and keep the same spaces in the last part otherwise the query
will fail.
TonyT
[quoted text clipped - 32 lines]