Solved

Restrict the length of a number

Posted on 2011-09-29
4
305 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
4 Comments
 
LVL 10

Expert Comment

by:ukerandi
ID: 36818335
0
 
LVL 92

Accepted Solution

by:
Patrick Matthews earned 250 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 250 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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Suggested Solutions

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
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…

910 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now