保存时自动生成客户端编号(Vb 6.0和MS Access) [英] Auto Generate Custome Number While Saving (Vb 6.0 and MS Access)

查看:89
本文介绍了保存时自动生成客户端编号(Vb 6.0和MS Access)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

VB 6.0和MS Access


在保存记录时,我想在下面生成数字格式


140208-001,140208-002,140208-003。 。 。等等...


您必须注意到140208是今天的日期和之后 - 最后3位数字。


现在我想要的是,让我们说如果我今天保存87条记录它应该是140208-087而第二天(明天)的数字应该是150208-001,150208-002等.....

如果可能,请告诉我如何?我使用以下代码自动生成数字,但格式不同。


=========我的代码在这里======== =


Dim C,E As String

Dim D As Integer

C =" ABCDEF"


如果Xrs.RecordCount = 0那么


D = 1


请不要Xrs.EOF

如果是Xrs(QNo)> D然后


结束如果


Xrs.MoveNext


D = D + 1


循环


如果D> = 1且D< 10然后

E = C& " 0000" &安培; D

Text1.Text = E

否则

如果D> = 10且D< 100然后

E = C& " 000" &安培; D

Text1.Text = E

否则

如果D> = 100且D< 1000然后

E = C& " 00 QUOT; &安培; D

Text1.Text = E

否则

如果D> = 1000且D< 10000然后

E = C& " 0" &安培; D

Text1.Text = E

否则

E = C& D

Text1.Text = E

结束如果

结束如果

结束如果

结束如果


Xrs.AddNew

Xrs(" QNo")。值= E


Text1.Text = Xrs.Fields(" QNo")

======代码在此结束===========
<
问候,


Hiren

Hi All,

VB 6.0 and MS Access

While Saving Record, I want Number to be Generated in following Format

140208-001, 140208-002, 140208-003 . . . etc...

You must have noticed that 140208 is today''s Date and After the - Last 3 digits are number.

Now what I want is, lets say If i save 87 Records today it should be 140208-087 and next day (tomorrow) numbers should be like 150208-001, 150208-002 etc.....

Please let me know if it possible then how? I m using the following code for Auto Generation of the Number but in different format.

=========My Code Goes Here =========

Dim C, E As String
Dim D As Integer
C = "ABCDEF"

If Xrs.RecordCount = 0 Then

D = 1

Do While Not Xrs.EOF
If Xrs("QNo") > D Then

End If

Xrs.MoveNext

D = D + 1

Loop

If D >= 1 And D < 10 Then
E = C & "0000" & D
Text1.Text = E
Else
If D >= 10 And D < 100 Then
E = C & "000" & D
Text1.Text = E
Else
If D >= 100 And D < 1000 Then
E = C & "00" & D
Text1.Text = E
Else
If D >= 1000 And D < 10000 Then
E = C & "0" & D
Text1.Text = E
Else
E = C & D
Text1.Text = E
End If
End If
End If
End If

Xrs.AddNew
Xrs("QNo").Value = E

Text1.Text = Xrs.Fields("QNo")

====== Code Ends Here ===========

Regards,

Hiren

推荐答案

第一部分使用系统日期。你只需要格式化日期。


第二部分找出那天插入的记录数。你的数字应该是+1。


接下来你需要根据需要对其进行格式化。


您需要在表格中存储日期字段。
For the first part use system date . You just need to format the date.

For the second part findout the number of records inserted in that day .You number should be +1.

Next you need to format it as desired.

You need to Store a date field in your table.





代码类似这样:

Hi,

Code Something like this :

展开 | 选择 | Wrap < span class =codeDivider> | 行号


是的我想到了同样的事情,但混淆了如何增加每日记录...我的意思是如何检查如果今天它是第一个记录还是第5或第8天?


我今天要试试,如果你能给我任何建议,将会对你有所帮助。


谢谢
Yes I thought of the same thing, but having confusion of how to Increment Daily Records... I mean how to check If today it is the first record or 5th or 87th?

I am going to try it today, if you can give me any suggestion on above will be helpful.

Thanks


这篇关于保存时自动生成客户端编号(Vb 6.0和MS Access)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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