SteveL13
asked on
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.
I tried ID: Val([textfieldname) but that didn't work.
Try using one of the conversion functions:
ID: CDbl(YourTextField)
ID: CDbl(YourTextField)
"Tried" how exactly...?
Post the SQL you tried...
try: cdbl(YourTextField)
...if you need decimals
...or clng() if you only have whole numbers
Post the SQL you tried...
try: cdbl(YourTextField)
...if you need decimals
...or clng() if you only have whole numbers
You can ignore my post...
other experts were there first..
other experts were there first..
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.
Don't use Join but Where:
Select
tblFirst.*,
tblSecond.*
From
tblFirst,
tblSecond
Where
tblFirst.IdNumeric = Val(tblSecond.IdText)
- or:
Where
Trim(Str(tblFirst.IdNumeri c)) = tblSecond.IdText
/gustav
Select
tblFirst.*,
tblSecond.*
From
tblFirst,
tblSecond
Where
tblFirst.IdNumeric = Val(tblSecond.IdText)
- or:
Where
Trim(Str(tblFirst.IdNumeri
/gustav
ASKER
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.
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.
ASKER
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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
BINGO!!! Thanks so much.
You are welcome!
/gustav
/gustav
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