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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

adding currencies 1

Status
Not open for further replies.

antdickens

Programmer
Nov 13, 2001
129
GB
I have two text boxes on a form which contain some currecny values.

I am trying to add these together and show in a third text box as a currency by

format((CLng(val1]) + (CLng[val2]),"currency")

this does not seem to be adding up properly is there a better way to add these together

 
If you just set the format of the text box you are going to display the total in as Currency then you won't have to do any of the above.

txtTotal = Text1 + Text2
 
This seems to be adding the values as strings and produces £3.50£4.20 in the text box.


Do i need to convert them into a different data type
 
Are you retrieving the values from a table where they are stored as currency values? If so I have had many problems with this in access. Now I always store currency values as a "Single" number and set the decimal places to 2. This means any calcs are pure number crunching where the final value can be displayed in whatever format you like.

If this is not the case: Could the incorrect value you are getting be a result of a rounding error?

Hope this helps

Stewart
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top