Results 1 to 5 of 5
  1. #1
    MatthewGrace is offline Competent Performer
    Windows 8 Access 2010 64bit
    Join Date
    Jan 2013
    Posts
    163

    limit number entry into a textbox

    Is there a way to force a textbox to contain a max of 2 digits to the right of a decimal, with a percent sign at the end? Examples: 32.25%, 15.1%, 12% would be accepted, but 11.999% would NOT because you can't type in the third 9.



    Importantly, this is not the same as using the format features of a textbox, because that allows you to type in lots of decimals but it only displays a couple.

  2. #2
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 10 Access 2016
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,536
    In your table, in the the properties for your field set your limitations.

  3. #3
    MatthewGrace is offline Competent Performer
    Windows 8 Access 2010 64bit
    Join Date
    Jan 2013
    Posts
    163
    The Decimal Places field properties doesn't seem to work as evidenced here:

    Click image for larger version. 

Name:	decimal places.jpg 
Views:	11 
Size:	105.2 KB 
ID:	29154

    Am I doing something totally wrong? I hope so...

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,646
    Only way I know with a number type field is to use VBA in BeforeUpdate event to validate the input.

    Ooops, forgot about Decimal and Percentage types. Never needed them.
    Last edited by June7; 06-19-2017 at 10:28 AM.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,706
    I suggest using Decimal and specify scale and precision properties in the table.
    Precision is the total number of digits in a number, including left and right of the decimal.
    Scale is the number of digits allowed to the right of the decimal.


    So 1234567.89 has a precision of 9.
    A precision of 4 and scale of 2 would result in a number with a maximun value of 99.99
    123456.789 has a scale of 3 and precision of 9.


    Percent designations like 125.5% would require precision 4 and scale of 3 (not one) since it is actually stored as 1.255.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Field default value + limit entry to numbers only
    By Lukael in forum Programming
    Replies: 8
    Last Post: 02-16-2016, 05:58 AM
  2. Replies: 5
    Last Post: 06-05-2015, 09:09 AM
  3. Replies: 7
    Last Post: 03-05-2015, 07:34 AM
  4. Limit data entry based on another field
    By chemengr in forum Forms
    Replies: 5
    Last Post: 01-02-2014, 01:21 PM
  5. Replies: 16
    Last Post: 10-13-2011, 07:52 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums