Automatically generate Date + 4-digit sequence num

2020-02-01 14:59发布

I need to automatically generate a 12 character value for my Business Key. Without any user interaction.

8 character -> Today Date        (yyyymmdd or ddmmyyyy).
+
4 character -> Sequential Number (0001,0002,0003).

The Sequential Number must reset on each new day.

Is it possible to do this in Microsoft Access 2010+ without any coding involved?

2条回答
爱情/是我丢掉的垃圾
2楼-- · 2020-02-01 15:39

Good question, thanks for the challenge!

After some search, it seems it's possible to do that.

You can prefix the AutoNuber value by processing like the explanation available here: http://www.databasedev.co.uk/add_prefix.html

You can try to specify in the format of the field a format(now(),"ddmmyyyy").

Check this page for more informations, another user seems to have the same problem and got a solution: http://bytes.com/topic/access/answers/695188-custom-made-autonumber-show-todays-date

Hope it's helping you!

查看更多
老娘就宠你
3楼-- · 2020-02-01 15:49

Since you are using Access 2010+ the best way to accomplish your goal would be to use a Before Change data macro like this

DataMacro.png

To create the Before Change macro, click the "Before Change" button on the "Table" tab of the ribbon when the table is open in Datasheet View:

BeforeChange.png

For more details on Data Macros see

Create a data macro

查看更多
登录 后发表回答