data type mismatch in criteria expression

gutmj

Registered User.
Local time
Today, 17:20
Joined
May 2, 2008
Messages
26
Hi All,

I have a simple query which throws an error (as in subject) on run.

SELECT tblItemMaster.SKU, tblItemMaster.MaterialDescription, MonthName(Month([LastRevision])) AS [Month], Year([LastRevision]) AS [Year], tblItemMaster.LastRevision
FROM tblItemMaster
GROUP BY tblItemMaster.SKU, tblItemMaster.MaterialDescription, MonthName(Month([LastRevision])), Year([LastRevision]), tblItemMaster.LastRevision;

Any thoughts? Thanks
 
Month and Year are poor choices for field names because those names are reserved for Access/VBA.

If the data type of [LastRevision] is not Date/Time it will throw this kind of error.

In the meantime, use this:
Code:
SELECT SKU, MaterialDescription, MonthName(Month([LastRevision])) AS [Month], Year([LastRevision]) AS [Year], LastRevision
FROM tblItemMaster;
 
Thanks for that. I will check if the data type can be changed to "date/time".
 
Thanks for that. I will check if the data type can be changed to "date/time".


If the Data looks like a date (mm/dd/yyyy), but the Data Type is Text, then you could use cDate() to change the type from Text to Date.
 
... but much better to set the data type in the underlying table.
 
... but much better to set the data type in the underlying table.

I completely agree with you here, that changing the data type would be the ideal solution to the problem. My experience, on the other hand, has been that I do not always have control over the Table Structures, and as a result, cannot change the format from Text to Date. The OP should change the data type if that is possible, and convert it if it is not.
 
My experience, on the other hand, has been that I do not always have control over the Table Structures, and as a result, cannot change the format from Text to Date.
It must get a bit frustrating when you're not allowed to do that ;)
 
Believe me that it is. Most of the time I was successful in getting the user to agree, but when a project has been in existence for a long time, Tables and Queries are used over and over, and a simple (and just) change like this one could have an effect on a lot of the Forms, Reports, and other code.
 

Users who are viewing this thread

Back
Top Bottom