Solved

"Data type mismatch in criteria expression", just by JOIN'ing to another table

Posted on 2013-05-14
5
653 Views
Last Modified: 2013-05-14
Hello, I have two tables, say "tblParents" and "tblChildren" (Access 2010). They both have primary keys that are AutoNumber fields (say "ParentKey" and "ChildKey"). tblChildren carries ParentKey field as a Number, Long Integer.

There is a Relationship defined that LEFT JOIN's tblParents!ParentKey to tblChildren!ParentKey, as One-To-Many, all 3 options checked for Ref Integrity, Cascading Updates & Deletes.

I can start with a query with just tblChildren, printing most of the fields, for all records. No problems. But when I add tblParents to the query, and the JOIN is automatically created from the Relationship, I get the "Data type mismatch in criteria expression" error message, even if I don't throw down any fields from tblParents.

I have checked for missing or bad values in the key fields in both tables, and checked for orphans in tblChildren. Everything seems ok.

Any ideas?
0
Comment
Question by:mlagrange
[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
5 Comments
 
LVL 77

Expert Comment

by:peter57r
ID: 39164498
We need to see the sql of the problem query.
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 250 total points
ID: 39164500
have you tried doing Compact and repair?
File > manage >compact and repair
0
 
LVL 61

Assisted Solution

by:mbizup
mbizup earned 250 total points
ID: 39164505
Did you post the exact syntax you have tried in your query?

You need to use periods, not exclamation marks:

..... LEFT JOIN ....  ON tblParents.ParentKey = tblChildren.ParentKey

If that is not the problem, then do you have any corrupted records in either table where the PK field might have been messed up?

Try Compact/Repairing your database.
0
 
LVL 61

Expert Comment

by:mbizup
ID: 39164568
Also, for kicks - try sorting tblChildren by ParentID.

Does that reveal any blanks/nulls in the ParentID field?  These may cause an error in your JOINs.
0
 

Author Comment

by:mlagrange
ID: 39165188
ok, I was filtering on a date field in tblChildren, which I was wrapping with DateValue() to get rid of the time component on some records, and that worked fine, until I JOIN'ed to tblParents, which had some parent records with no children, as it turns out...

"WHERE DateValue(tblChildren!ChildDate) <= #04/30/2013#  "

The filtering on the expression that assumed a value in the date field was what was causing the error message, when it hit the nulls.

I reversed the lay-out of the query, LEFT JOIN'ing  tblChildren to tblParents, and that side-steps the "childless" parent records.

Thank you for your responses
0

Featured Post

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.

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

627 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