Assigning a variable to "LIKE" condition search string

pikachew

Registered User.
Local time
Tomorrow, 02:37
Joined
Jan 26, 2005
Messages
34
Hi can anyone help me with this query?

'SQLTable "Resolutions Per Year", "SELECT ResName, COUNT(ResName) AS Total FROM Stats LEFT JOIN Resolutions ON (Stats.UserID = Resolutions.UserID AND Stats.ResID=Resolutions.ResID) WHERE Stats.UserId = '"&login&"' AND Date LIKE '%sYear%' GROUP BY Stats.UserID, ResName ORDER BY COUNT(ResName) DESC"

sYear is a variable
example sYear = 2003,2004,2005....

This does not work.
Is there anyway to assign the search string to be a variable?
 
Come On, you posted this in General and Tables forum.
 
Sorry will restrict to General from now onwards
:)
 
I use variables with Like all the time....e.g.
SELECT TblSeminar.* FROM TblSeminar
WHERE (((TblSeminar.[DfES No]) Like [Forms]![FrmP3AllEntry]![dfes]));


In this example, [Forms]![FrmP3AllEntry]![dfes] will have a * in it or a number of a number followed by an *. However, if you are using a date field, I think you need the field surrounded by #. For example:

[SchDay]= #" & Format(dblCurrentDate, "m-d-yy") & "#"

or

[date]= " & "#" & Me![inseminardate] & "#"

I am in Europe which is why I have to use the format. I don't have time right now to find a solid example of where I use "like" with the above but will look tomorrow if you still need help. Hope that helps some.
 
Thanks a lot JT
Problem has been solved.
As advised by FoFa previously in another thread, i do not really have to use the LIKE condition. But will keep in mind of your suggestion if i need to use it in the future.
Thanks again.
 
Yup Pat.
I have already apologized.(See previous posts)
New to the forum.
Wont do it again.
Thanks for the advise.
 

Users who are viewing this thread

Back
Top Bottom