Update Query losing decimal precision

G

Guest

I have an update query that needs to take decimal values (presented as text)
from a table (Tbl_3) and insert them into corresponding NUMERIC fields in
another table (Tbl_2), keeping the precision.

Here is what I have tried:

UPDATE Tbl_3, Tbl_2
SET Tbl_2.Final_Technical_Score = Val(Tbl_3.Technical_Score),
Tbl_2.Calculated_Result_Quadrant = Tbl_3.Calculated_Disposition
WHERE Tbl_2.ID=Tbl_3.ID;

UPDATE Tbl_3, Tbl_2
SET Tbl_2.Final_Technical_Score = CDbl(Tbl_3.Technical_Score),
Tbl_2.Calculated_Result_Quadrant = Tbl_3.Calculated_Disposition
WHERE Tbl_2.ID=Tbl_3.ID;

UPDATE Tbl_3, Tbl_2
SET Tbl_2.Final_Technical_Score = CDbl(Tbl_3.Technical_Score)*.01,
Tbl_2.Calculated_Result_Quadrant = Tbl_3.Calculated_Disposition
WHERE Tbl_2.ID=Tbl_3.ID;

UPDATE Tbl_3, Tbl_2
SET Tbl_2.Final_Technical_Score = CDec(Tbl_3.Technical_Score),
Tbl_2.Calculated_Result_Quadrant = Tbl_3.Calculated_Disposition
WHERE Tbl_2.ID=Tbl_3.ID;

As an example, if I have a value of 3.7912345 in Tbl_3.Technical_Score, no
matter which of the commands above I use, I always get a resulting value in
Tbl_2.Final_Technical_Score of "4" with no decimals. It is rounded and the
precision is lost.

(In the 3rd example, I tried to force precision by multiplying the value by
..01, but what I really want in Tbl_2.Final_Technical_Score is exactly what I
started with (3.7912345).

What am I doing wrong?!?!?
 
G

Guest

I'm assuming that you ran these statements as Select queries first to see the
returns were what you expected.

Check the field sizes in the fields receiving the data. Make sure that they
are set to Double. If they are Byte, Integer or Long Integer, they will be
converted to integers. The Numeric datatype has about 7 different field sizes.
 
G

Guest

Boy am I red faced!!! As much as making that simple mistake as from banging
my head against the wall all afternoon. I had copied the table structure
from a SQL Server View into my local mdb, then copied the data in. I did
this to enable testing. Unfortunately, the data lost its precision on the
copy from the View!

So, now that I found that out, with your help, I changed the Update query to
utilize the View as the source of the data, and lo and behold I cannot do so
because the View is not updatable, which it must be to use this type of
update query!

Looks like I will create a stored procedure, which I should have started
working on in the first place!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top