Trying to run an update query

I have an update query design with the source and the destination tables in the query designer.  But the joined fields are a text field in one table and a number field in the other table.   So naturally I'm getting a type mismatch error.  Is there some way to convert the text field to a number?  It will always truly be a number.

I tried ID: Val([textfieldname) but that didn't work.
SteveL13Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Kelvin SparksCommented:
Try CInt(txtfield) if it is an integer you're joining to

If a long integer use CLng(txtfield)
or a double
CDbl(txtfield)

These will fail howver - if there are ANY non numeric values in the column.


Kelvin
0
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
Try using one of the conversion functions:

ID: CDbl(YourTextField)
0
Jeffrey CoachmanMIS LiasonCommented:
"Tried" how exactly...?
Post the SQL you tried...

try: cdbl(YourTextField)
...if you need decimals

...or clng() if you only have whole numbers
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Jeffrey CoachmanMIS LiasonCommented:
You can ignore my post...
other experts were there first..
0
PatHartmanCommented:
If you have control of the tables, the correct solution is to fix the data type discrepancy.  Otherwise, one the various type conversions already suggested will work.
0
Gustav BrockCIOCommented:
Don't use Join but Where:

Select
   tblFirst.*,
   tblSecond.*
From
   tblFirst,
   tblSecond
Where
   tblFirst.IdNumeric = Val(tblSecond.IdText)

- or:

Where
   Trim(Str(tblFirst.IdNumeric)) = tblSecond.IdText

/gustav
0
SteveL13Author Commented:
I just tried :

Select
    tblFirst.*,
    tblSecond.*
 From
    tblFirst,
    tblSecond
 Where
    tblFirst.IdNumeric = Val(tblSecond.IdText)

But I get an error indicating that I can't use asterisks and that I need to add each field to the grid.

What should the code look like?  I have 13 fields in total.
0
SteveL13Author Commented:
Ok.  I have attached a file that I created by stripping everything else out of the real database.  I cannot get the update query to work because I'm sure I'm doing something wrong.  Can someone help?

Notes:

The ID field in tblNotes is numeric and has to be.
The ID field in tblTEMPORARY is text and has to be.

--Steve
Update-Qry-Example.accdb
0
Gustav BrockCIOCommented:
It does matter which field you apply VAL on.
This is how:

WHERE Val(tblTEMPORARY.NotesID)=[tblNotes].[NotesID];

/gustav
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SteveL13Author Commented:
BINGO!!!  Thanks so much.
0
Gustav BrockCIOCommented:
You are welcome!

/gustav
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.