Solved

Access 2007 "Data Type Mismatch Criteria Expression"

Posted on 2013-02-01
8
1,588 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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
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

As with any other System Center product, the installation for the Authoring Tool can be quite a pain sometimes. This article serves to help you avoid making these mistakes and hopefully save you a ton of time on troubleshooting :)  Step 1: Make sur…
Many companies are making the switch from Microsoft to Google Apps (https://www.google.com/work/apps/business/). Use this article to learn more about what Google Apps has to offer and to help if you’re planning on migrating to Google Apps. It is …
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

839 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