Solved

Access 2007 "Data Type Mismatch Criteria Expression"

Posted on 2013-02-01
8
1,568 Views
Last Modified: 2013-02-06
Good day. So I have an Access database that I use to produce some reports and store data. I receive a CSV file every month which contains the data, I have a module that I run to import the data, process it by moving the current data in a table to another table which contains all the archived data, then I import the CSV data in the existing table.

Well, today i received the file and after importing the data and attempting to run the report, I receive an error stating "Data Type Mismatch Criteria Expression".

I took a look at the file and it seems like the date fields changed. They changed as follows:

From: Mon May 3 21:00:00 GMT-0700 2010

To: 11/23/2010 20:07

Any idea what changes I would need to make to get the reports to work?
0
Comment
Question by:mig1980
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 16

Expert Comment

by:terencino
Comment Utility
Possibly the new CSV is being imported into a field that is now a Date/Time data type in your initial table. This can happen sometimes as Access is smart enough to recognize data types from text imports. The problem may be that in your archive table, that field is a text field, and when you try and append the data, it needs to match the fields. You said your module is handling that? Can you provide that here? I think you would just change the append query so the field is converted to a string instead eg CStr(DateImport) instead of just DateImport
Hope that helps
...Terry
0
 

Author Comment

by:mig1980
Comment Utility
I checked the data types of the table where the new data came in to and it still states Text as data type. all fields are text in that table.

The data seems to be appended fine to the archive table. The error arises when I try to run the report which pulls data from the original table that has the new imported data.
0
 
LVL 16

Expert Comment

by:terencino
Comment Utility
Sorry I missed that in your original question. In your report, do you use a query or is it based directly on the table? Do you use any criteria on that field to filter the records for the report?
0
 
LVL 92

Expert Comment

by:Patrick Matthews
Comment Utility
Please post the SQL statement for your query
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 

Author Comment

by:mig1980
Comment Utility
There is a query for the report. There is criteria to filter but nothing related to the date fields (which are the only ones that changed).

Here is the query with the issue. If I look at the Datasheet View of this query, I can see errors represented in the "CreationDateOnly", "LastLogin", and "UserStatus" fields. All other show correct.

SELECT MSUser.[Last Name], MSUser.[First Name], MSUser.[User Id], MSUser.Role, MXUser.Email, Mid([Email],InStr(1,[Email],"@")+1) AS EmailDomain, MSUser.Status, MSUser.[Creation Date], IIf([Creation Date]<>"null",CDate(Mid([Creation Date],InStr(1,[Creation Date]," ")+1,6) & " " & Right([Creation Date],4)),Null) AS CreationDateOnly, MSUser.[Last Login Date], IIf([Last Login Date]<>"null",CDate(Mid([Last Login Date],InStr(1,[Last Login Date]," ")+1,6) & " " & Right([Last Login Date],4)),Null) AS LastLoginDateOnly, GetUserStatus(nz([LastLoginDateOnly],#1/1/1900#),[CreationDateOnly]) AS UserStatus
FROM MSUser
WHERE (((MSUser.Status)="Active"));

Open in new window

0
 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 500 total points
Comment Utility
My guess is that the UserStatus calculated field will correct itself once you get the date fields working correctly ...
...So, ... as far as the CreationDate and LastLogInDate, fields are concerned, you can change your query to something like this:

SELECT MSUser.[Last Name], MSUser.[First Name], MSUser.[Creation Date], IIf(IsNull([Creation Date]),Null,CDate(Left([Creation Date],InStr([Creation date]," ")-1))) AS CreationDateOnly, MSUser.[Last Login Date], IIf(IsNull([Last Login Date]),Null,cdate(Left([Last Login Date],InStr([Last Login Date]," ")-1))) AS LastLogInDate
FROM MSUser;

;-)

See the attached sample
Access-EEQ-28017543-CovertTextDa.mdb
0
 

Author Comment

by:mig1980
Comment Utility
This worked great. Thank you
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
Comment Utility
;-)
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Article by: Leon
Software Metering within our group of companies has always been an afterthought until auditing of software and licensing became a pain point. Orchestrator and SCCM metering gave us the answer and it was an exciting process.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

763 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

9 Experts available now in Live!

Get 1:1 Help Now