Solved

Type Mismatch

Posted on 2011-02-16
4
369 Views
Last Modified: 2012-05-11
I have a table with an autonumber field called VenId.  The id is 10 char and looks like 0000000001.  I want to join two tables together by this VenId field.  Issue is, the VenId field in the second table is formatted as text (to hold the leading zeros) so I'm getting a TypeMismatch error.  I tried changing the VenId field to Number, but when I do this, the leading zeros in the id disappear.  What's the best way to solve this?
0
Comment
Question by:vsllc
  • 2
4 Comments
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 34913110
so you already know that to join two fields, they must be of the same data type.

if you want to see the leading zero, you can always do that in a query

select format([id],"0000000000") as myID from table
0
 
LVL 51

Accepted Solution

by:
HainKurt earned 500 total points
ID: 34913126
best way is make both fileds number...
if this is not possible then use

select *
from table1 a left join table2 b on a.id=right("0000000000" & b.id,10)
0
 
LVL 51

Expert Comment

by:HainKurt
ID: 34913131
or

select *
from table1 a left join table2 b on CLng(a.id)=b.id

0
 

Author Comment

by:vsllc
ID: 35118595
This worked.  Thanks!
0

Featured Post

Backup Your Microsoft Windows Server®

Backup 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

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
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.

863 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now