In a form I have 2 fields one is as Decimal # and another as Amount(Real).
Decimal # is an Enum having values from 1-5 and default value will be 5.
Requirement:
1) Whenever value is selected for Decimal # field (1-5), depending upon the value selected
No of decimal should be allowed in Amount field.
Ex1: If Decimal # = 2
Amount = 1.24
Ex2: If Decimal # = 3
Amount = 1.521
Ex1: If Decimal # = 4
Amount = 3.0124
Ex1: If Decimal # = 5
Amount = 8.02145
Solution: I wrote modified method on Decimal # control level, so depending on value selected for Decimal # it will allow that many decimals for Amount field. This much is working fine, now.
But as shown in above examples the Amount field of all the records in the grid changes according to Decimal # in latest row entered.
Means, First row: if Decimal # = 2 then Amount = 1.02
Second row: If Decimal # = 3 then Amount = 4.623
But that time first row also takes limit as 3 though the Decimal # = 2.
Please guide me in this regard.
Sorry, but there is no reliable way to have different number of decimals in a grid control.
The change for the current record may affect other records displayed in the grid.
For a group control the number of decimals is easily adjusted like this:
In the grid, you could try using a edit method with a string value. You will have to do the conversion yourself.
The
DecimalStrextended data type should be right aligned.Unfortunately
str2numaccepts only period as the decimal point and does not accept thousand seperators, so it is not a “user friendly” function for numeric conversion. You may have to make you own to take account of regional settings.