请问我写的这个自动生产编号的程序为什么会出问题
Dim rs As New ADODB.RecordsetDim cnn As New ADODB.Connection
Private Sub Command1_Click()
rs.Open "select * from guest order by 编号", cnn, adOpenKeyset, adLockOptimistic
If rs.RecordCount > 0 Then
rs.MoveLast
Text1.Text = Format(Val(rs.Fields("编号")) + 1, "00000")
Else
Text1.Text = "00001"
End If
rs.Close
End Sub
Private Sub Command2_Click()
rs.Open "ABC", cnn, adOpenKeyset, adLockOptimistic
rs.AddNew
rs!编号 = Text1.Text
rs.Update
rs.Close
MsgBox "保存成功!"
Unload Me
End Sub
Private Sub Form_Load()
cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Store Findeway Management.mdb;Persist Security Info=False"
End Sub
以上是我写的代码
我需要实现的是自动编号
点一下command1
text1会自动生成编号
点command2
将会自动保存
我感觉没什么问题了
但是我生成的编号一直是00001
很无奈
求大神解释一下