A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Database Design
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Field format



 
 
Thread Tools Display Modes
  #1  
Old February 17th, 2010, 05:15 PM posted to microsoft.public.access.tablesdbdesign
szag via AccessMonster.com
external usenet poster
 
Posts: 99
Default Field format

I need to have a project number that forces ensures that the field has 5
parts:

1. Always the letter C
2. Last two years of Year
3. 3 digit number (sequential)
4. "-"
5.2 digit sequential (usually just 00)

So the first Project in 2010 will be : C10000-00, 2nd will be C10001-00, 3rd
C10002-00 and so on

How do I enforce this in the field - both in the table and in the form...

Thanks!

--
Message posted via http://www.accessmonster.com

Ads
  #2  
Old February 17th, 2010, 06:02 PM posted to microsoft.public.access.tablesdbdesign
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Field format

On Wed, 17 Feb 2010 17:15:42 GMT, "szag via AccessMonster.com" [email protected]
wrote:

I need to have a project number that forces ensures that the field has 5
parts:

1. Always the letter C
2. Last two years of Year
3. 3 digit number (sequential)
4. "-"
5.2 digit sequential (usually just 00)

So the first Project in 2010 will be : C10000-00, 2nd will be C10001-00, 3rd
C10002-00 and so on

How do I enforce this in the field - both in the table and in the form...

Thanks!


This is called an "Intelligent Key" - and that is unfortunately not a
compliment!

Two basic principles of relational database design are that fields should be
"atomic" - containing only one fact; and that no field should depend on any
other field (except for the primary key). This field violates both. Another
good rule is that you shouldn't store repeated data - the C and the - are
there in every record, just wasting space.

I would really construct this project number as needed from multiple pieces.
You could use a (concealed, hidden from the user) Autonumber as the project
ID, and have fields for ProjectDate, SeqNo, and SecondarySeqNo, with a unique
index on the three fields; you can construct your project number by
concatenating the pieces:

ProjectNo: "C" & Format([ProjectYear], "yy") & Format(SeqNo, "000") &
Format([SecondarySeqNo], "\-00")

--

John W. Vinson [MVP]
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 11:57 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
Copyright 2004-2019 OfficeFrustration.
The comments are property of their posters.