Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with adding field values 1

Status
Not open for further replies.

Razor1

IS-IT--Management
Nov 21, 2002
81
US
I have a table with values I need to add together and write them to the same table.

When all the fields except one equal 0 and the one field has a negative number. I get "Data Type Conversion Error".

All the fields that are being added are numeric.

Here is the code i am using.
rstMainTbl!CYrTot = rstMainTbl!Test1CYr + rstMainTbl!Test2CYr + rstMainTbl!Test3CYr + rstMainTbl!Test4CYr + rstMainTbl!Test5CYr

Any help would be greatly appreciated.



Razor1
 
What is the data type of each of your CYr fields ?
Does the following query give expected result ?
SELECT Test1CYr, Test2CYr, Test3CYr, Test4CYr, Test5CYr, Test1CYr+Test2CYr+Test3CYr+Test4CYr+Test5CYr AS TotCYr
FROM yourTable

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
All fields are numeric Number (Double)

The query does give the correct results.

Any idea why the code does not?



Razor1
 
Why not simply use an update query ?
UPDATE yourTable
SET CYrTot = Test1CYr+Test2CYr+Test3CYr+Test4CYr+Test5CYr
WHERE ...

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I will use a query.

I am curious why the code would not work. Any ideas.

Thanks for the help.....Have a star

Razor1
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top