Solved

Data type mismatch

Posted on 2011-03-25
12
186 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
 

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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 

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

Suggested Solutions

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

920 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now