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

Round a number in a list box

Status
Not open for further replies.

Seeff

Programmer
Dec 2, 2002
33
IL
Hi...I have a listbox that lists a field containing numbers. The numbers have many decimal places and I would like to show them in the listbox with only one decimal place. For eg. instead of 1.2345 I would like to see 1.2 in the list box.

Any ideas and thanks for your replies.
 
If you use Access 2000/XP, you have the Round function.
For Access 97, Paste this into a module:

Function DnRound(Expression As Double, Optional decimals = 2) As Double
DnRound = Int(Expression * 10 ^ decimals + 0.5) / (10 ^ decimals)
End Function

Then, change the row source of the listbox: instead of
Select FieldName From TableName
make it:
Select Round(FieldName, 1) As RoundedValue from tableName)
Of course, for Access 97 Round should be replaced by DnRound.

Good luck

[pipe]
Daniel Vlas
Systems Consultant
 
Works fine and a thank you very much!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top