W
William Wisnieski
Hello Everyone,
I have a query by form with several list boxes. The user selects items from
the list boxes and clicks a button that returns results in a datasheet
subform.
One of the list boxes [lstStatus] contains two values: Call Back and No
Answer. The user can select either one or both and the proper results are
returned. If the user doesn't use this list box, then all Call Backs, No
Answers, and Null values are returned. As another option, I would like the
user to be able to select ONLY those records where the value of the field is
Null.
What code could I add to do that? Here is what I have that works as stated
above:
If Me!lstStatus.ItemsSelected.Count > 0 Then
If Len(strWhere) > 0 Then
strWhere = strWhere & "AND" & "[Status] IN ("
For i = 0 To lstStatus.ListCount - 1
If lstStatus.Selected(i) Then
strWhere = strWhere & "'" & lstStatus.Column(0, i) & "', "
End If
Next i
strWhere = Left(strWhere, Len(strWhere) - 2) & ")"
Else
strWhere = strWhere & "[Status] IN ("
For i = 0 To lstStatus.ListCount - 1
If lstStatus.Selected(i) Then
strWhere = strWhere & "'" & lstStatus.Column(0, i) & "', "
End If
Next i
strWhere = Left(strWhere, Len(strWhere) - 2) & ")"
End If
End If
Thanks for your help!
William
I have a query by form with several list boxes. The user selects items from
the list boxes and clicks a button that returns results in a datasheet
subform.
One of the list boxes [lstStatus] contains two values: Call Back and No
Answer. The user can select either one or both and the proper results are
returned. If the user doesn't use this list box, then all Call Backs, No
Answers, and Null values are returned. As another option, I would like the
user to be able to select ONLY those records where the value of the field is
Null.
What code could I add to do that? Here is what I have that works as stated
above:
If Me!lstStatus.ItemsSelected.Count > 0 Then
If Len(strWhere) > 0 Then
strWhere = strWhere & "AND" & "[Status] IN ("
For i = 0 To lstStatus.ListCount - 1
If lstStatus.Selected(i) Then
strWhere = strWhere & "'" & lstStatus.Column(0, i) & "', "
End If
Next i
strWhere = Left(strWhere, Len(strWhere) - 2) & ")"
Else
strWhere = strWhere & "[Status] IN ("
For i = 0 To lstStatus.ListCount - 1
If lstStatus.Selected(i) Then
strWhere = strWhere & "'" & lstStatus.Column(0, i) & "', "
End If
Next i
strWhere = Left(strWhere, Len(strWhere) - 2) & ")"
End If
End If
Thanks for your help!
William