Results 1 to 9 of 9

Thread: decimal placing

  1. #1
    Join Date
    Jul 2004
    Posts
    56

    Unanswered: decimal placing

    Hi All

    I have a database (that's probably why i'm posting in here!). In one of the fields on a form a list box works out the averages of weights of a particular items or items that have been recorded elsewhere on the database. The weights are coming out like (3.4332223) I want them to show this with only two digits after the decimal points.

    Any ideas, please.I have tried changing the properties on the query behind the list box but this doesn't seem to do anything.

    Thanks


    col_bol

  2. #2
    Join Date
    Feb 2004
    Location
    Chicago, IL
    Posts
    1,312
    I would put a calculated field in the query that returns the number as a formatted string. Something like:

    FormattedWeight:Format([Weight],"0.00") for two decimal places

    This assumes the name of the Weight field is Weight.

  3. #3
    Join Date
    May 2004
    Location
    New York State
    Posts
    1,178
    Don't worry about the extra decimal places in the query itself, because the user doesn't see that. All he sees is the info in the List Box. As long as you set the List Box's Property Sheet to display only 2 decimal places, that's all he'll see.

    Sam

  4. #4
    Join Date
    Feb 2004
    Location
    Chicago, IL
    Posts
    1,312
    Sam Landy

    What version are you using? How would you do that, specifically? I have never seen anything that will allow you to format the columns in a List Box. However I have been using 97 for several years until recently when we upgraded to 2002. I have always hated not being able to format the data in a list box.

  5. #5
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Yes ... I'd be most interested in how you can do that too Sam ... What property of the ListBox is it now????
    Back to Access ... ADO is not the way to go for speed ...

  6. #6
    Join Date
    Feb 2005
    Posts
    333
    You can quantize your data using the following formula:

    roundedWeight = Round(Me.weight * 100) / 100

    In other languages I would use the Floor function so that the number is never rounded up but I can't find this function in VBA.

  7. #7
    Join Date
    May 2004
    Location
    New York State
    Posts
    1,178
    Ulp, you guys are right, and I'm eating the crow. Chomp, chomp.

    My work around was similar to Campster's, as follows. I forced the information using the Round() function, namely: Round(PCTWeight, 5). This forces the data into a maximum of 5 decimal places. I then save the info in a table. The list box source is a query based on the table, and always limits the decimals properly. I only use the number "5" because I need precision, as I'm dealing with a high-dollar application. I use "2" in another app, and it works properly there, too.

    Sam

  8. #8
    Join Date
    Jul 2004
    Posts
    56

    Thanks

    Thanks to everyone - you would of thought Mr Gates would have just made a little drop down box so you can format the list box !!

    How good is he really?
    col_bol

  9. #9
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    wonder what would happen if you changed the format of the trext box to fixed and set the number of decimals to 2?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •