Results 1 to 3 of 3
  1. #1
    4 Star Lounger
    Join Date
    Feb 2001
    Location
    Gillingham, Kent, England
    Posts
    511
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Decimal places problem (Access 97 SR2)

    Is there a way to set decimal places on a text box so that only 2 can be entered? The decimals setting shows 2 decimals, but you can enter more than 2.

    If there isn't a way to do this, I guess ill have to validate the number entered and delete anything after the 2nd decimal. Its currency and would be a typing error therefore it would be rounded down, so I can safely remove any further figures.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Decimal places problem (Access 97 SR2)

    Officially, you can't set an input mask for currency fields, but ####.## might work (use as many #'s before the decimal point as needed). The user won't "see" the input mask, but it will be enforced.

    Alternatively, you can enforce two decimals in a form bound to the table. Use the AfterUpdate event of the text box bound to the currency field to drop any decimals past the second.

    Private Sub CurrencyField_AfterUpdate()
    CurrencyField = Fix(CurrencyField * 100) / 100
    End Sub

    You'll have to make sure that your users can't edit the table directly, only through the form.

  3. #3
    4 Star Lounger
    Join Date
    Feb 2001
    Location
    Gillingham, Kent, England
    Posts
    511
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Decimal places problem (Access 97 SR2)

    Excellent, ill give it a go, thanks Hans.

Posting Permissions

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