Solved

Access 2007 "Data Type Mismatch Criteria Expression"

Posted on 2013-02-01
8
1,608 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

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
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

724 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