View Single Post
  #2  
Old May 5th, 2010, 04:38 PM posted to microsoft.public.access.forms
Dorian
external usenet poster
 
Posts: 542
Default Multi Select For Query

"I cannot get it to work if the field is of a Date type."
What does this mean? What happens?
It sounds like you need to treat date data as a string, you can use CStr()
function?
-- Dorian
"Give someone a fish and they eat for a day; teach someone to fish and they
eat for a lifetime".


"Ryan" wrote:

I have copied the following code into my Database however I cannot get it to
work if the field is of a Date type. I can change the varValue data type from
Variant to Date however this then damages all other fields. Any ideas?

Function IsSelectedVar( _
strFormName As String, _
strListBoxName As String, _
varValue As Variant) _
As Boolean
'strFormName is the name of the form
'strListBoxName is the name of the listbox
'varValue is the field to check against the listbox
Dim lbo As ListBox
Dim item As Variant
If IsNumeric(varValue) Then
varValue = Trim(Str(varValue))
End If
Set lbo = Forms(strFormName)(strListBoxName)
For Each item In lbo.ItemsSelected
If lbo.ItemData(item) = varValue Then
IsSelectedVar = True
Exit Function
End If
Next
End Function