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

Numeric Field Problem

Status
Not open for further replies.

richmond88

IS-IT--Management
Sep 25, 2003
32
GB
Hi All,

I am running an append query and in that query there is a calulation.

The answer could come out as 6.597489 - this figure is appended into a field in a temporary table that is numeric, fixed, with Decimal Places of 1.

The problem I am having is that in the temporary table the figure shows up as say 6.5 which is what I want, but I click on the cell and I will see the 6.597489 - this causes me a problem in that I have a lookup table which is expecting to see 6.5, 6.6, 6.7, 6.8 etc. Therefore non of the records are linking up.

Any answers will be greatatfully received.

Chris
 
Hallo,

When you append, instead of appending [valueofcalculation]
append val(format$([valueofcalculation],"0.0"))

By converting to a string with one decimal place, then converting that back to a number, you'll force the field to store the number to 1 DP.

However, this could still be a problem, if you are using this field as a link.
Non-integer values are stored in strange ways and are not always exact. ie. 2.4 might be stored as 2.399999997 (for instance). The number 2.3999999996 would also be shown as 2.4, but the numbers would not be the same.

I would suggest storing any values to be used for linking as longs (ie, keep the number in the tables as the number*10, so 2.4 is stored as 24, and you divide it by 10 whenever you need it, using CDbl([storedvalue]/10) is always good)
or store it as a string, using format$([actualvalue],"0.0") to write it and val([storedvalue] to read it.

Hope that makes sense,

- Frink
 
Cheers Frink,

That worked beautifully, I just used the Val and format$ commands.

Once again Thanks you.

Chris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top