Solved

Access 2007 "Data Type Mismatch Criteria Expression"

Posted on 2013-02-01
8
1,586 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
ID: 38845803
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
ID: 38845812
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
ID: 38845997
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
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 38846895
Please post the SQL statement for your query
0
 

Author Comment

by:mig1980
ID: 38851809
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
ID: 38853372
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
ID: 38860836
This worked great. Thank you
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 38861237
;-)
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

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…
The new Microsoft OS looks great, is easier than ever to upgrade to, it is even free.  So what's the catch?  If you don't change the privacy settings, Microsoft will, in accordance with the (EULA) you clicked okay to without reading, collect all the…
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

832 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