?
Solved

Access 2007 "Data Type Mismatch Criteria Expression"

Posted on 2013-02-01
8
Medium Priority
?
1,623 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

 
LVL 93

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 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

764 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