读书人

小弟我想当日期为新的一天时编号重新

发布时间: 2012-04-25 19:32:32 作者: rapoo

我想当日期为新的一天时,编号重新为01,请帮忙看看怎么改
Dim tmpNote As Integer
Dim rs1 As New ADODB.Recordset
rs1.Open "select * from 交库单 ", cnn, adOpenKeyset, adLockOptimistic
If rs1.RecordCount > 0 Then
If Not rs1.EOF Then rs1.MoveLast
If rs1.Fields("交库单编号") <> "" Then
tmpNote = Val(Right(Trim(rs1.Fields("交库单编号")), 2)) + 1
txtNote.Text = Date & " -" & Format(tmpNote, "00")
End If
Else
txtNote.Text = Date & " -" & "01"
End If
rs1.Close

我想当日期为新的一天时,编号重新为01,

[解决办法]
Dim tmpNote As Integer
Text1 = Date & " -" & "01"
Adodc2.ConnectionString = "Provider=Microsoft.ace.OLEDB.12.0;Data Source=" & App.Path & "\storage.accdb" & ";Persist Security Info=False"
Adodc2.RecordSource = "select 交库单编号 from 交库单 where 交库单编号='" + Trim(Text1.Text) + "'"
Adodc2.Refresh
If Adodc2.Recordset.RecordCount > 0 Then
Adodc2.Recordset.MoveLast
tmpNote = Val(Right(Trim(Adodc2.Recordset.Fields("交库单编号")), 2)) + 1
txtNote.Text = Date & " -" & Format(tmpNote, "00")
Else
txtNote.Text = Date & " -" & "01"
End If

读书人网 >VB

热点推荐