Results 1 to 5 of 5
  1. #1
    5 Star Lounger
    Join Date
    Jul 2001
    Location
    NJ, USA
    Posts
    617
    Thanks
    0
    Thanked 0 Times in 0 Posts

    FormatNumber (AccessXP)

    I am trying to get my math to be displayed with 1 place after the decimal. My code is

    Private Sub txtWeight_AfterUpdate()
    Dim MyBMI As Integer
    MyBMI = (txtWeight / (txtHeight * txtHeight)) * 703
    txtBMI = FormatNumber(MyBMI, 1)
    End Sub

    The answer should be 27.8, but I keep getting 28.

    In the table the two fields txtWeight and txtHeight are long integar data types. On the form I have no format for any of the three text boxes and the decimal place field is currently at Auto. I have tried setting this value.

    Thank you for your help.

    Fay

  2. #2
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    USA
    Posts
    386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: FormatNumber (AccessXP)

    Integar data type does not have a decimal component.
    Try changing the data type to Double.
    Richard

  3. #3
    5 Star Lounger
    Join Date
    Jul 2001
    Location
    NJ, USA
    Posts
    617
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: FormatNumber (AccessXP)

    Thanks for your response. That didn't do the trick.

  4. #4
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    USA
    Posts
    386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: FormatNumber (AccessXP)

    In your DIM statement you have the result dimed as an Integer. This should also be a Double.
    Richard

  5. #5
    5 Star Lounger
    Join Date
    Jul 2001
    Location
    NJ, USA
    Posts
    617
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: FormatNumber (AccessXP)

    Oops. Didn't catch that. That did the trick. Thank you very much! Fay

Posting Permissions

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