大家好,欢迎来到IT知识分享网。
先在ACCESS数据库里做一个流水号字段的表
然后在VB工程里建如下表单
功能是点击接单后自动生成流水号,当后面的日期变更后流水号自动变更
实现代码如下:
Private Sub DTPicker1_Change()
Call OpenConn
Dim rs0 As New ADODB.Recordset
Dim BH As String
rs0.Open “select 流水号 from 流水历史 where 流水号 like ‘%” & “J” & Format(Me.DTPicker1.Value, “yyyymmdd”) & “%’ order by 流水号 DESC “, cn, adOpenKeyset, adLockOptimistic
If rs0.RecordCount <= 0 Then
BH = 1
Else
BH = Mid(rs0.Fields(“流水号”), 10, 3) + 1
End If
rs0.Close
Set rs0 = Nothing
Me.Text1.Text = “J” & Format(Me.DTPicker1.Value, “yyyymmdd”) & Format(BH, “000”)
End Sub
Private Sub Form_Load()
Me.Text1.Text = “”
Me.DTPicker1.Enabled = False
Me.DTPicker1.Value = Date
Me.接单.Enabled = True
End Sub
Private Sub 接单_Click()
Me.DTPicker1.Enabled = True
Me.DTPicker1.Value = Date
Call OpenConn
Dim rs0 As New ADODB.Recordset
Dim BH As String
rs0.Open “select 流水号 from 流水历史 where 流水号 like ‘%” & “J” & Format(Date, “yyyymmdd”) & “%’ order by 流水号 DESC “, cn, adOpenKeyset, adLockOptimistic
If rs0.RecordCount <= 0 Then
BH = 1
Else
BH = Mid(rs0.Fields(“流水号”), 10, 3) + 1
End If
rs0.Close
Set rs0 = Nothing
Me.Text1.Text = “J” & Format(Date, “yyyymmdd”) & Format(BH, “000”)
Me.接单.Enabled = False
End Sub
预览一下结果:
免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://yundeesoft.com/160817.html