473,327 Members | 1,976 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

SQL Data Type Mismatch

207 100+
So I have a SQL Query I am trying to author and it keeps giving me a Data Type mismatch error which I can't seem to see. Exact error message is Data type mismatch in criteria expression.

Here is the SQL...

Expand|Select|Wrap|Line Numbers
  1. SELECT Count(*) AS NumTests, ConvertDate(IssuedDate)
  2. FROM ItasWithCancelledTests
  3. GROUP BY ConvertDate(IssuedDate);
  4.  
Here is my Function Convert Date

Expand|Select|Wrap|Line Numbers
  1. 'This method converts a date into a required format
  2. 'valid items for the format are:
  3. 'Day for day
  4. 'Week for week
  5. 'Month for month
  6. 'Year for year
  7. Public Function ConvertDate(dt As Date) As Date
  8. On Error GoTo Err_ConvertDate
  9.     Dim format As String
  10.  
  11.     'If the person hasn't entered a dateFilter set it to Day
  12.     format = Nz(TempVars("dateFilter"), "Day")
  13.  
  14.     Select Case format
  15.         Case "Day"
  16.             ConvertDate = dt
  17.         Case "Week"
  18.             ConvertDate = DateAdd("ww", DatePart("ww", dt, , vbFirstJan1) - 2, DateSerial(DatePart("yyyy", dt), 1, 1))
  19.         Case "Month"
  20.             ConvertDate = DateSerial(DatePart("yyyy", dt), DatePart("m", dt), 1)
  21.         Case "Year"
  22.             ConvertDate = DateSerial(DatePart("yyyy", dt), 1, 1)
  23.         Case Default
  24.             ConvertDate = Date
  25.             MsgBox "Unable to recognize format"
  26.     End Select
  27.  
  28.  
  29. Exit_ConvertDate:
  30.     Exit Function
  31.  
  32. Err_ConvertDate:
  33.     MsgBox Err.Description
  34.     Resume Exit_ConvertDate
  35. End Function
  36.  
  37.  
I have verified that the field IssuedDate is a Date field and if I take away the User designed function then it works properly. Anybody see a problem in my logic here.
Apr 8 '11 #1

✓ answered by hype261

I just figured it out. I had used the function before it a different app so I was pretty sure it worked. The difference between the two was that in my other app the date field was marked as required where in this one the date field is not marked as required. This allowed Access to mark my Date as a Nullable Date where my function is looking for a Non Null Date.

2 3144
Rabbit
12,516 Expert Mod 8TB
Nothing jumps out at me as being wrong. Have you tried stepping through the code?
Apr 8 '11 #2
hype261
207 100+
I just figured it out. I had used the function before it a different app so I was pretty sure it worked. The difference between the two was that in my other app the date field was marked as required where in this one the date field is not marked as required. This allowed Access to mark my Date as a Nullable Date where my function is looking for a Non Null Date.
Apr 8 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Chicken Kebab Abdullah | last post by:
Does anyone know why I get the error 3464 Data type mismatch from the following code. I have a form with a combo(to choose a consumable) and 2 list boxes on it. list on left is all printers...
0
by: news.paradise.net.nz | last post by:
I have been developing access databases for over 5 years. I have a large database and I have struck this problem with it before but can find nothing in help or online. Access 2000 I have a query...
1
by: ArcadeJr | last post by:
Good morning all! I have been getting a Run-time Error message #3464 - Data Type mismatch in criteria expression. While trying to run a query. I have a database where the field Asset_Number...
3
by: Jake | last post by:
I am currently trying to create my own Point Of Sale software for my retail store. I wrote the program with the UPC field as Long integer. When I started to add the products by UPC code, I got a...
1
by: amitbadgi | last post by:
I am getting the following error while converting an asp application to asp.net Exception Details: System.Runtime.InteropServices.COMException: Data type mismatch in criteria expression. ...
2
by: psychomad | last post by:
Please, can someone help me out to solve this error, i've been searching throughout my codes and yet i didnt succeed in finding the error!!!! The Error is: Server Error in '/' Application....
19
by: Lysander | last post by:
I have written a query that takes three integers representing day,month and year, forms a date from them and compares this date to the date the record was entered and returns any records where the...
3
by: Bruce Lawrence | last post by:
I've got a form that when it opens it prompts the user for 2 peices of information. The Asset and the Date. getasset = InputBox("Enter the Asset Number") If getasset = "" Then Exit Sub Else...
1
by: Bobby Edward | last post by:
Using Access db with VS2008 (ASP.NET/VB.NET).... On the INSERT command I get this error: System.Data.OleDb.OleDbException: Data type mismatch in criteria expression. I haven't found a...
3
by: charli | last post by:
SQL: SELECT COUNT(month) as c FROM pool WHERE = "GP06NHL" AND = "43.38" AND = "NORMAL UNLEADED" AND = #01/04/2009# Gives 'Data Type Mismatch' because the 43.38 is delimited as a...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.