开发者

generating customer ID: prefixed with alpha characters

I'm planning to make a simple helpdesk form. One of the attributes it needs is a unique number.

How can I create a unique ident开发者_Python百科ifier, starting with a string? Example: KL0001 and KL0002

It must be a number which is unique.


You could use a standard AutoNumber field to store the numerical portion, and then a separate Calculated column that formats the result prefixing "KL" and padding the AutoNumber field with the necessary zeros.

Example:

SELECT "KL" & Fmt(autonum_field, "0000") AS unique_identifier
FROM YourTable;


The problem with using an autonumber is, among other things, if someone starts to enter the record the autonumber is assigned. Then, if the user cancels adding the record the autonumber value is lost. So you are better to wait until the user finishes entering the record and in the forms AfterInsert event run the code as per the following KB article.

ACC2000: How to Create a Multiuser Custom Counter

That said I'd still use an autonumber field in the table so that it's easier to work with child tables.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜