Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
600 views
in Technique[技术] by (71.8m points)

ms access - Customized Auto-Number IDs for tables?

Is there a way to use my own number in a table like an auto-number; that is to automatically assign the next available to a new record. We have system ID numbers for each employee that I want to tie into this database. I just want the table to auto assign the next number.

Can I do this?
Could this be done with a mixture of numeric and alpha?
Could criteria be used, like Code A = certain set of numbers, Code B = another?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Of course you can, but you will have to design this yourself.

There are hundreds of ways of doing this but one way might be that you may have a parameters table with "nextQuote", "nextEmployeeNo", "nextJob"... of course your table design could have anything, including prefix example;

PARAMETERS
Prefix    Number
Q          1145
E            54
J           999

So now you can SELECT PreFix + MAX(Number) AS NextEmployee FROM Parameters WHERE Prefix = E

And in your code you can increment the number after dealing with it.

UPDATE Parameters SET Number = number + 1 WHERE Prefix = E 

If this isn't up to the job then hopefully it will get you thinking in how you can do something similar.

Hope this helps.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...