Solved

Data type mismatch

Posted on 2011-03-25
12
187 Views
Last Modified: 2012-06-27
When I run the following query I get an error: "Data type mismatch in criteria expression"

If I remove the SMARTQtr expression the query runs ok.  What is wrong with the SMARTQtr expression?  It seems to work in other queries.  Thanks.
0
Comment
Question by:RishiSingh05
12 Comments
 
LVL 75
ID: 35217483
You will probably need to post the SQL for your query :-)

mx
0
 

Author Comment

by:RishiSingh05
ID: 35217488
Yes !! I forgot  ...

SELECT "Members" AS Id, Left(Revenue.SMARTMth,4) & " Q" & DatePart("q",DateSerial(Left(Revenue.SMARTMth,4),Mid(Revenue.SMARTMth,5),1)) AS SMARTQtr, [Cohort] & " " & [Dual/Medicaid] AS Cohort2, Sum(Revenue.[Member Count]) AS [SumOfMember Count]
FROM Revenue LEFT JOIN 6CareODSCohort ON (Revenue.[Subscriber ID] = [6CareODSCohort].MedicaidID) AND (Revenue.SMARTMth = [6CareODSCohort].Month)
GROUP BY "Members", Left(Revenue.SMARTMth,4) & " Q" & DatePart("q",DateSerial(Left(Revenue.SMARTMth,4),Mid(Revenue.SMARTMth,5),1)), [Cohort] & " " & [Dual/Medicaid];
0
 
LVL 75
ID: 35217516
I'm not seeing a Criteria expression or SMARTQtr   ?? Is there a missing WHERE clause ?

mx
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

Author Comment

by:RishiSingh05
ID: 35217576
There is no missing WHERE clause.  This is the expession for SMARTQtry:

SMARTQtr: Left(Revenue.SMARTMth,4) & " Q" & DatePart("q",DateSerial(Left(Revenue.SMARTMth,4),Mid(Revenue.SMARTMth,5),1))
0
 
LVL 77

Accepted Solution

by:
peter57r earned 500 total points
ID: 35217632
Can't see anything obvious .
What is the datatype of smartmth?
0
 

Author Comment

by:RishiSingh05
ID: 35217657
text
0
 

Author Comment

by:RishiSingh05
ID: 35217702
This query works.  It does not have the expression:
SMARTQtr: Left(Revenue.SMARTMth,4) & " Q" & DatePart("q",DateSerial(Left(Revenue.SMARTMth,4),Mid(Revenue.SMARTMth,5),1))
===

SELECT "Members" AS Id, Revenue.SMARTMth, [Cohort] & " " & [Dual/Medicaid] AS Cohort2, Sum(Revenue.[Member Count]) AS [SumOfMember Count]
FROM Revenue LEFT JOIN 6CareODSCohort ON (Revenue.SMARTMth = [6CareODSCohort].Month) AND (Revenue.[Subscriber ID] = [6CareODSCohort].MedicaidID)
GROUP BY "Members", Revenue.SMARTMth, [Cohort] & " " & [Dual/Medicaid];
===
0
 

Author Comment

by:RishiSingh05
ID: 35217766
Now it works !!

SELECT "Members" AS Id, Left([Revenue].[SMARTMth],4) & " Q" & DatePart("q",DateSerial(Left([Revenue].[SMARTMth],4),Mid([Revenue].[SMARTMth],5),1)) AS SMARTQtr, [Cohort] & " " & [Dual/Medicaid] AS Cohort2, Sum(Revenue.[Member Count]) AS [SumOfMember Count]
FROM Revenue LEFT JOIN 6CareODSCohort ON (Revenue.SMARTMth = [6CareODSCohort].Month) AND (Revenue.[Subscriber ID] = [6CareODSCohort].MedicaidID)
GROUP BY "Members", Left([Revenue].[SMARTMth],4) & " Q" & DatePart("q",DateSerial(Left([Revenue].[SMARTMth],4),Mid([Revenue].[SMARTMth],5),1)), [Cohort] & " " & [Dual/Medicaid];
0
 

Author Comment

by:RishiSingh05
ID: 35217793
I have two databases.  The above SQL works in one db but not in the other ...
0
 
LVL 22

Expert Comment

by:8080_Diver
ID: 35217899
Okay, then you need to compare the datatypes in the two databases for the [Revenue] table and any other tables involved in that bit of the WHERE clause.
0
 

Author Comment

by:RishiSingh05
ID: 35217952
ok
0
 

Author Comment

by:RishiSingh05
ID: 35244065
To summarize my problem:

The following query works ok:
===
SELECT "Members" AS Id, Revenue.SMARTMth, [Cohort] & " " & [Dual/Medicaid] AS Cohort2, Sum(Revenue.[Member Count]) AS [SumOfMember Count]
FROM Revenue LEFT JOIN 6CareODSCohort ON (Revenue.SMARTMth = [6CareODSCohort].Month) AND (Revenue.[Subscriber ID] = [6CareODSCohort].MedicaidID)
GROUP BY "Members", Revenue.SMARTMth, [Cohort] & " " & [Dual/Medicaid];
===

But if I change SMARTMth to this expression: SMARTQtr: Left([Revenue.SMARTMth],4) & " Q" & DatePart("q",DateSerial(Left([Revenue.SMARTMth],4),Mid([Revenue].[SMARTMth],5),1))

so that the query becomes:
===
SELECT "Members" AS Id, Left([Revenue.SMARTMth],4) & " Q" & DatePart("q",DateSerial(Left([Revenue.SMARTMth],4),Mid([Revenue].[SMARTMth],5),1)) AS SMARTQtr, [Cohort] & " " & [Dual/Medicaid] AS Cohort2, Sum(Revenue.[Member Count]) AS [SumOfMember Count]
FROM Revenue LEFT JOIN 6CareODSCohort ON (Revenue.SMARTMth = [6CareODSCohort].Month) AND (Revenue.[Subscriber ID] = [6CareODSCohort].MedicaidID)
GROUP BY "Members", Left([Revenue.SMARTMth],4) & " Q" & DatePart("q",DateSerial(Left([Revenue.SMARTMth],4),Mid([Revenue].[SMARTMth],5),1)), [Cohort] & " " & [Dual/Medicaid];
===

I get an error message:  "Data type mismatch in criteria expression"
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question