grabbing displayed value versus actual field value

  • Thread starter Thread starter Thomas Becker
  • Start date Start date
T

Thomas Becker

Field value is 45.678 but field displays $45.68 as its format is set to
currency. This is good.

Question: Is there a way to get the value that is displayed (45.68) rather
than the contents of the field?

Background: I know there are many other issues here with regards to the data
and possible ways to convert the data, etc. It would make for a simpler fix
if I could read the "value" being displayed and use it in another field.

This relates to me trying to fix a check printing application where the
check amount field is showing the $45.68 but the code that prints the
Forty-Five dollars and sixty seven cents is not rounding and is thus off a
penny.. - If I can just pass it the displayed number I don't have to fix the
code that is initially calculating the amount nor the code that translates
the money into words. This application is going away soon so a "quick" fix
would be great.

Thank you.
 
Thomas Becker said:
Field value is 45.678 but field displays $45.68 as its format is set to
currency. This is good.

Question: Is there a way to get the value that is displayed (45.68) rather
than the contents of the field?
This relates to me trying to fix a check printing application where the
check amount field is showing the $45.68 but the code that prints the
Forty-Five dollars and sixty seven cents is not rounding and is thus off a
penny.. - If I can just pass it the displayed number I don't have to fix the
code that is initially calculating the amount nor the code that translates
the money into words. This application is going away soon so a "quick" fix
would be great.

Thomas,

you'd need a rounding function. Here's a function I found in my
collection, maybe it helps:

Public Function varCustomRound(ByRef varValue As Variant, _
ByVal intDecimalPlaces As Integer) As Variant

' Author: Jayden MacRae
' Round a value to the specified number of decimal places.
' Function returns null if it can't be evaluated.
' --------------------------------------------------------

If Not IsNumeric(varValue) Or intDecimalPlaces < 0 Then
varCustomRound = Null
Exit Function
End If

varCustomRound = CInt("" & (varValue * 10 ^ intDecimalPlaces)) _
/ 10 ^ intDecimalPlaces

End Function

You could call it like this:

curResult = varCustomRound(Me![MyCurrencyField], 2)

Best regards
Emilia

Emilia Maxim
PC-SoftwareService, Stuttgart
http://www.maxim-software-service.de
 
Back
Top