Charlih Chen Posted April 18, 2006 Posted April 18, 2006 As Subject: How to do it? The unique number generate by current date. For example, I like to have an index number field called POR# (Purchase Order Request number). The number has the 7 digit format: ymmdd## eg. Today is 2006/4/18, the first POR# will be 6041801. The second POR# will be 6041802 The third POR# will be 6041803 ... etc. BTW, I have the following function working for the ymmdd, but I don't know how to get the last 2 digit to work. Also, the mm seems to has only 1 digit, since it April, so the mm became 4 instead of 04. POR# = Right(Year ( Get ( CurrentDate ) ); 1) & Month (Get ( CurrentDate ) )&Day ( Get ( CurrentDate ) )
-Queue- Posted April 18, 2006 Posted April 18, 2006 Though I would probably recommend using two digits for the year, instead of one, what you desire can be accomplished via both calculations and scripts. If you are in a single-user situation, then calculations are fine. If you are in a multi-user situation, then it is safest to script the solution. However, I would not use the POR as the key field in either scenario, but merely as a visual reference. The key field for relationships is best when absolutely unique and meaningless, such as an auto-entered serial number, and virtually unseen by users. To prepend zeroes to months and/or days, you can use Right( "0" & ValueOrFunctionProducingValue; 2 )
Charlih Chen Posted April 19, 2006 Author Posted April 19, 2006 I have an idea to have the POR# searching the newest POR# for today. And then increase it by 1. Do you think the idea is good for a not single user input envirnment?
sbg2 Posted April 19, 2006 Posted April 19, 2006 Why do you need a number in this format? There is a definate potential for problems using the formulas you provided: a) as -Queue- mentioned the Year being only 1 character limits your number to ten years. the last 2 digits limit you to 99 requests per day. You may think it will never last ten years or that no more than 99 requests will ever be made in a day but **** happens. Wasn't it Bill Gates who said no-one will ever need more than 1MB of memory? ... oops.
Recommended Posts
This topic is 7140 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now