Access 2003自动编号“定义我自己的友善指南", [英] Access 2003 autonumber Define My Own Kindly Guide ,

查看:133
本文介绍了Access 2003自动编号“定义我自己的友善指南",的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题..

表名
J_voucher

字段是:
凭证编号,日期,旁白,借方,贷方

凭证编号的自动编号:
我想要这样的自动编号 JV-TodayDate-000AutoNumber

My Qustion..

Table Name
J_voucher

Fields are:
Voucher Number, Date , Narration , Debit , Credit

Autonumber on Voucher Number:
I want Autonumber Like That JV-TodayDate-000AutoNumber

推荐答案

访问提供了自动编号:它被称为自动编号"字段,令人惊讶.同样不足为奇的是,它只是数字...

我将凭证代码分开:凭证号是自动编号字段,日期字段是TodayDate,然后使用string.Format:
从中构建凭证代码.
Access provides autonumber: it is called an "autoNumber" field, surprise, surprise. Also unsurprisingly, it is numeric only...

I would keep the Voucher code separate: The Voucher number is the Autonumber field, the Date field is the TodayDate, and build the voucher code from that using string.Format:
string voucherCode = string.Format("JV-{0}-000{1}", date.ToString("yyyy-MM-dd"),voucherNumber);


如果创建后需要检索信息,我也建议使用Guid作为PK字段.

我还建议使凭证代码更加复杂:如果我收到了具有这种格式的凭证,可能会想尝试相同的日期,但是如果我是一个顽皮的类型想要欺骗您,则我会尝试少一位或多一位数字. ..


I would also recommend using a Guid as the PK field if you will need to retrieve the information once you have created it.

I would also recommend making the voucher code a little more complex: If I received a voucher with that format, I might be tempted to try the same date, but one digit less / more if I was a naughty type who wanted to cheat you...


这篇关于Access 2003自动编号“定义我自己的友善指南",的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆