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

Formatting decimal places <> field value 1

Status
Not open for further replies.

bfwriter

Technical User
Jul 22, 2006
35
US
Hi guys,

I am stumped by how to input and display numeric values in a grid's textboxes, where the number of decimal places for the user differs from that of the underlying table.

E.g-- All the fields in the underlying table are (always) N (10,4). But we need the user to be able to select and change between 0, 2 and 4 decimals, for both input and display.

If I make the InputMask = "99999.99", the two decimal places are maintained as long as the cursor remains in the textbox; but as soon as the cursor exits the field, it reverts to the table decimal places of 4.

Also I've tried SET DECIMALS TO [N], and this has no effect.

Any thoughts?

TIA
 
bfwriter,

Why do you want to restrict the user to 2 decimal places when there are 4 in the data?

You could try setting the Sparse property of the column to .F. This is usually used for showing the whole column but might affect the InputMask.

If some other data determines how many decimal places the user can edit, you could try using the DynamicCurrentControl property of the column.

Alternatively, you may just have to have some code in the textbox to validate what the user is doing.

Hope that helps,

Stewart
PS If you want to get the best response to a question, please check out FAQ184-2483 first.
 
You could try using the TRANSFORM function as part of the control source for the column, where the mask is a variable set at the time when the user selects the number of decimals to display.


--------------
Good Luck
To get the most from your Tek-Tips experience, please read
FAQ181-2886
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
You would set Format:R, Inputmask: 99999.99 (eg) and Sparse: .F.

Try to set these properties either in the Column, the Textbox or both. I think the Columns' settings have precedence over the textbox properties.

Bye, Olaf.
 
Many thanks, Olaf. That's exactly what I am trying to achieve.

Thanks also to StewartUK and CajunCenturion for your help. And to answer Stewart's question about why use a 2-decimal format to report a 4-decimal field... it's because in some cases the user will be working with monetary units which have been calculated yielding >2 decimals (e.g. $1000/3=$333.3333), but should be viewed and written as 2 decimals.

Thanks again.
Bill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top