Link to home
Start Free TrialLog in
Avatar of Sandra Smith
Sandra SmithFlag for United States of America

asked on

EXCEL VBA SQL statement to ACCESS 2003 not working

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?


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
Avatar of Norie

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Sandra Smith


Yes, the percentage worked.