I am trying to pull time records for employees. I have a list box (simple multi select) with there names in the box. I want people to be able to select the employees that they want, and click the view report button. Its not working.
my code is
my sqlbox is what i am referring to in the query (i only use the qry wizard, i cant seem to do better, lol)
My question is... if i manually type
"Name1" OR "Name2"
in the crieteria box (in the query wizard, then the query returns the results. The code above produces the same result for the query
"Name1" OR "Name2"
but it wont pull results. I did notice that if i put Name1
(without quotes) it works fine, so i know somehow it is turning the txtbox into a string... how do i stop it from doing that... I tried
name1" or "name2
just to see if it would try to turn it into a string, and then separate the OR from the string, but that didnt work. I have tried """ and all kinds of crazy stuff, but no good results yet
I did read http://www.fontstuff.c om/access/acctut18.htm but it wasnt much help for the query I am trying to build. To be honest, i am certain that the info was there, but i am grouping data, and again, I am not really good at SQL so maybe the answer is there...but i figured the method i was trying was a bit more streamlined, and would work.
Thanks in advance for any help.
my code is
Code:
Dim VarItem As Variant
Dim strEmployee As String
strEmployee = """"
For Each VarItem In Me.EmployeeTime.ItemsSelected
strEmployee = strEmployee & Me.EmployeeTime.ItemData(VarItem)
strEmployee = strEmployee & """ Or """
Next VarItem
If Len(strEmployee) = 0 Then
strEmployee = "Like *"
Else
strEmployee = Left(strEmployee, Len(strEmployee) - 5)
End If
Me.SQLBox = strEmployee
End Sub
My question is... if i manually type
"Name1" OR "Name2"
in the crieteria box (in the query wizard, then the query returns the results. The code above produces the same result for the query
"Name1" OR "Name2"
but it wont pull results. I did notice that if i put Name1
(without quotes) it works fine, so i know somehow it is turning the txtbox into a string... how do i stop it from doing that... I tried
name1" or "name2
just to see if it would try to turn it into a string, and then separate the OR from the string, but that didnt work. I have tried """ and all kinds of crazy stuff, but no good results yet
I did read http://www.fontstuff.c om/access/acctut18.htm but it wasnt much help for the query I am trying to build. To be honest, i am certain that the info was there, but i am grouping data, and again, I am not really good at SQL so maybe the answer is there...but i figured the method i was trying was a bit more streamlined, and would work.
Thanks in advance for any help.
Comment