Dale Fye said:
If you are trying to do this as a parameter query, where you run the
query,
an input box pops up, and you enter data as you have perscribed, then I
think
you are out of luck.
No, it could be done, but it would be very inefficient. One would write a
function along the lines of this very quick and dirty one:
'----- start of code -----
Function ValueIsInList( _
InputValue As Variant, _
ListSpec As String) _
As Boolean
Static strList As String
Static alngValueList() As Long
Dim astrItems() As String
Dim astrRange() As String
Dim I As Long
' New spec, build new list.
If ListSpec <> strList Then
strList = ListSpec
astrItems = Split(strList, ",")
ReDim alngValueList(UBound(astrItems), 1)
For I = 0 To UBound(astrItems)
astrRange = Split(astrItems(I), "-")
alngValueList(I, 0) = CLng(astrRange(0))
If UBound(astrRange) = 0 Then
alngValueList(I, 1) = alngValueList(I, 0)
Else
alngValueList(I, 1) = CLng(astrRange(1))
End If
Next I
End If
' Is the value in the list?
ValueIsInList = False
If Not IsNull(InputValue) Then
For I = 0 To UBound(alngValueList, 1)
If InputValue >= alngValueList(I, 0) _
And InputValue <= alngValueList(I, 1) _
Then
ValueIsInList = True
Exit Function
End If
Next I
End If
End Function
'----- end of code -----
Then one could call it in a parameter query like this:
SELECT * FROM MyTable
WHERE ValueIsInList(MyTable.Section, [Enter section(s) wanted:])
As I said, it would be very inefficient, but it would work.
--
Dirk Goldgar, MS Access MVP
www.datagnostics.com
(please reply to the newsgroup)