Results 1 to 5 of 5
  1. #1
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Ephrata, Washington, USA
    Posts
    683
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Specify number of characters in a field (2003)

    How can I set a validation in a table field to specify that the number of characters allowed in a field is 10? And, can I set this after there is already data in the db in the field?

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

    Re: Specify number of characters in a field (2003)

    You can set the Field Size property of the field to 10. When you save the table design, Access will warn you that text will be truncated. If you confirm, all values in the field will be truncated to a maximum length of 10 characters.

  3. #3
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Ephrata, Washington, USA
    Posts
    683
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Specify number of characters in a field (2003)

    Thanks, but I want the field to have exactly 10 characters - no more, no fewer. So, how can I tell it not just a maximum, but exactly 10 characters.

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

    Re: Specify number of characters in a field (2003)

    OK, setting the Field Size to 10 will ensure that the user can't enter more than 10 characters. To force the user to enter exactly 10 characters, enter the following in the Validation Rule property of the field:

    Len([FieldName])=10

    where FieldName is the name of the field. Also enter an appropriate warning text in the Validation Message property.

    If the field already contains data when you save the table design with the new validation rule, Access will ask you if want to test the existing data. If you answer Yes, Access will tell you whether existing data violate the validation rule, but it won't tell you which records this concerns. You can save the table design, and the validation rule will apply to everything you do with the field from then on, both in existing records and in new records.

  5. #5
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Ephrata, Washington, USA
    Posts
    683
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Specify number of characters in a field (2003)

    Perfect! Thank you - that's exactly what I wanted, and it works great.

Posting Permissions

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