Problem with Primary key

michalgut25

Registered User.
Local time
Today, 07:47
Joined
Jan 28, 2013
Messages
15
I would like to define primary key to show in default value "n/=Right(Year(Date());2)"
n - next real number
=Right(Year(Date());2) - equal two last digits from year
The big problem is when we have next year e.g. 2014 real number should count anew.

E.G 6/13, 7/13, 8/13, 9/13, 1/14

I tried to write some code to Expression Builder in default value but I think it's to hard for me.
Guys please help.
 
Google, or search this site, for 'meaningful vs meaningless keys.' A human readable key adds no value to your project. If your customer wants one, fabricate one after the user has entered data in the record and it will be lots easier to do then, after the record already exists.
 
It must be that key because so far it was paper orders (with that key) for many years and now it will be electronic database with the same rules.
 
lagbolt is right.

the value of a key is unimportant as far as the database is concerned. it's the relatedness of tables that matters.

do not use an artificial key such as the one you desdcribe to link this table to others. use an autonumber key - if you must have the structured field, then add it to the main table as an extra key/field. you won't see any difference in the system operation - except that it will be far more efficient with numeric primary keys.

over time, I am sure you will begin to move away from the restrictions imposed by the previous system.

but anyway - use the forms beforeupdate event to evaluate and set the key you want. you will need a dmax to find the highest value in the table for the relevant year. I wouldn't store the whole thing (year) 13/742 - just store the 742. it is trivial to derive the expression 13/742 when ever you need it.

eg something like

year(trandate) mod 2000 & "/" & sequential number
 
Last edited:

Users who are viewing this thread

Back
Top Bottom