Results 1 to 8 of 8
  1. #1
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581

    I want exactly 10 characters

    I have a field in a form, report number. It has to have 10 characters. I made the max 10 characters in the table. However, users can still enter less than 10. I don't want less than 10 characters, I want exactly 10. How would I go about doing that?

  2. #2
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    If it's a number field you cold format as 0000000000 so numbers with less than 10 digits will be preceded by leading zeroes as necessary.
    If it's text, use an input mask or possibly a validation rule.
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  3. #3
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581
    It's a text field. I have an input mask, but the mistake is still being done. The zeros won't work because I don't want any zeros preceding it.

  4. #4
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    You can use a Validation Rule right on the table field itself, or you can use some BeforeUpdate VBA script on the Form.
    This example shows both ways: https://www.pcreview.co.uk/threads/v...field.2934160/

  5. #5
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,643
    Are these existing report numbers or are they making them up?
    If existing use a combobox.
    If they are making them up, are duplicates allowed?

  6. #6
    JSR is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2018
    Location
    Reno, NV
    Posts
    41
    validation rule Len([field name])=10

  7. #7
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581
    The report numbers are given. Yes, duplicates are allowed.

    JoeM, that worked perfectly. Thanks.

  8. #8
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    You are welcome.

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

Similar Threads

  1. Exclude characters
    By cself in forum Queries
    Replies: 4
    Last Post: 09-27-2017, 01:25 PM
  2. Need grouping by last four characters
    By dan@goditmaderanch.com in forum Access
    Replies: 7
    Last Post: 12-05-2016, 01:30 PM
  3. Replies: 5
    Last Post: 05-02-2016, 12:41 PM
  4. Replies: 9
    Last Post: 02-11-2013, 03:09 PM
  5. erase characters at the end
    By bjelinski in forum Access
    Replies: 14
    Last Post: 07-05-2010, 12:03 PM

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