Solved

Type Mismatch

Posted on 2011-02-16
4
368 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
Comment Utility
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
Comment Utility
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
Comment Utility
or

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

0
 

Author Comment

by:vsllc
Comment Utility
This worked.  Thanks!
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Familiarize people with the process of utilizing SQL Server stored procedures 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 Micr…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

771 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

10 Experts available now in Live!

Get 1:1 Help Now