EXCEL VBA SQL statement to ACCESS 2003 not working

Sandra Smith
Sandra Smith used Ask the Experts™
on
I have the below statement that does work in the ACCESS 2003 database.  However, it does not run.  If I take out the WHERE clause of TblCompletedTask.TaskiD LIKE '*CON*', it will run.  So, how can I get the EXCEl VBA code to recognize the like statement?  Or will it even do that?

Sandra

sSQL = "SELECT TblCompletedTask.TaskDate, tblUsers.DeptID, TblDepartment.DeptName, [LastName] & ', ' & [FirstName] AS FullName, " & _
    "TblTaskCategory.CatName AS TaskCategory, tblTasks.Description AS Task, [TaskTimeTotal]/[Tasktime] AS TaskCount " & _
    "FROM ((tblUsers INNER JOIN ((TblCompletedTask INNER JOIN tblTasks ON TblCompletedTask.TaskID = tblTasks.TaskID) " & _
    "INNER JOIN TblTimeSheet ON TblCompletedTask.TSID = TblTimeSheet.TSID) ON tblUsers.UserID = TblTimeSheet.UserID) " & _
    "INNER JOIN TblTaskCategory ON tblTasks.CatID = TblTaskCategory.CatID) INNER JOIN TblDepartment ON " & _
    "tblTasks.DeptID = TblDepartment.DeptID " & _
    "WHERE TblCompletedTask.TaskID Like '*CON*' AND tblUsers.DeptID = " & intDeptID
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Analyst Assistant
Commented:
Sandra

How are you using this SQL?

Have you set up a connection to the Access database to run it in?

You could try replacing the * with %.
Sandra SmithRetired

Author

Commented:
Yes, the percentage worked.

Sandra

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial