Hi!
I have continuos form! in this form, i have field "Amount". I want to format this texbox with different decimal place in different row.
ex:
R/M Amount
-----------------
A 10.23
B 9.245
C 12.5623
How do i do?
Hi!
I have continuos form! in this form, i have field "Amount". I want to format this texbox with different decimal place in different row.
ex:
R/M Amount
-----------------
A 10.23
B 9.245
C 12.5623
How do i do?
You can use a calculated field like this:
Code:AmountToShow: IIf([R/M]="A",Round([Amount],2),IIf([R/M]="B",Round([Amount],3),IIf([R/M]="C",Round([Amount],4),[Amount])))
Be aware that Round() function uses even/odd rule, in case that matters to you.
Round(10.225,2) = 10.22
Round(10.226,2) = 10.23
Round(10.235,2) = 10.24
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
You could also use the Format function, but just bear in mind that returns a Text value (not a numeric one).
Code:FORMAT([Amount],"0.00")
Which is why I built a custom function,
Code:Function RRound(FieldValue As Variant, Optional intPos As Integer = 0) As Variant '-------------------------------------------------- ' Function RRound() rounds value to designated decimal position. ' If argument does not contain data, RRound returns null. ' Use because intrinsic Round uses even/odd (banker's) rounding. ' Also, Format and FormatNumber functions don't use even/odd but ' generate a string result which is often inconvenient. '-------------------------------------------------- Dim strZeros As String Dim i As Integer If intPos = 0 Then strZeros = 0 Else For i = 1 To intPos strZeros = strZeros & 0 Next strZeros = "0." & strZeros End If RRound = IIf(Not IsNull(FieldValue), Val(Format(FieldValue, strZeros)), Null) End Function
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
Nice! Gotta love those UDFs!Which is why I built a custom function,