Data Type Mismatch criteria expression

tjones

Registered User.
Local time
Yesterday, 20:30
Joined
Jan 17, 2012
Messages
199
When I run this query everything works

SELECT Sum(tblCourseTaken.Units) AS TotalCredits, tblCourseTaken.[790ID]
FROM tblCourseTaken
GROUP BY tblCourseTaken.[790ID], tblCourseTaken.CourseStatus
HAVING (((tblCourseTaken.CourseStatus)="Completed"));


When I try and narrow it down from all to just "required" (which in the table is 1-Required and i also tried replacing "required with 1"

SELECT Sum(tblCourseTaken.Units) AS TotalCredits, tblCourseTaken.[790ID], tblCourseTaken.CourseTypeID
FROM tblCourseTaken
GROUP BY tblCourseTaken.[790ID], tblCourseTaken.CourseTypeID, tblCourseTaken.CourseStatus
HAVING (((tblCourseTaken.CourseTypeID)="Required") AND ((tblCourseTaken.CourseStatus)="Completed"));


I get the data type mismatch error
 
The issue is this portion of your code:

Code:
HAVING (((tblCourseTaken.CourseTypeID)="Required") AND ((tblCourseTaken.CourseStatus)="Completed"));

It's comparing CourseTypeID and CourseStatus to string data. Most likely one of those fields holds data that is not a string. I didn't really understand your explanation of "required" and replacing it with "required with 1", but you should see if either of those 2 fields hold numeric data instead of string data and then change the above code accordingly.
 

Users who are viewing this thread

Back
Top Bottom