Solved

Type Mismatch

Posted on 2011-02-16
4
373 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
[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
  • 2
4 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
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 55

Accepted Solution

by:
Huseyin KAHRAMAN 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 55

Expert Comment

by:Huseyin KAHRAMAN
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

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!

Question has a verified solution.

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

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

728 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