?
Solved

Restrict the length of a number

Posted on 2011-09-29
4
Medium Priority
?
342 Views
Last Modified: 2012-05-12
Experts,
In my table I have to restrict the size of  numeric and text feilds to be specific length. I wanted to define this in the table. For example, field OriginID's numeric length mus be 10 or CompanyName's length must be 16.
0
Comment
Question by:Frank Freese
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 93

Accepted Solution

by:
Patrick Matthews earned 1000 total points
ID: 36818507
fh_freese,

For text, it's easy: put your table in design view, and you will see in the column definitions that you can specify the text length.

For numbers it's harder.  For example, the Long data type can accept SOME 10-digit numbers, but only up to about 2.1 billion.  You may be better off using a text field for your "numeric" OriginID if you really need 10 digits.

(You could use the Double data type, which allows for larger numbers and stores up to 15 significant digits, but depending on how you are using it, that can introduce new problems...)

Patrick
0
 
LVL 74

Assisted Solution

by:Jeffrey Coachman
Jeffrey Coachman earned 1000 total points
ID: 36840692
Numbers really don have a "Length"

If you define this field as Text in the table, and only allow numbers to be entered, then yes, what you are asking is possible.

Set the FieldSize property of this "numbers only" Text field to: 10
Set the InputMask property of this "numbers only" Text field to: 9999999999

JeffCoachman
0
 

Author Closing Comment

by:Frank Freese
ID: 36893511
thank you
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Suggested Courses

741 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question