I'm moving a database from an Access backend to a SQL Server 2005 backend.
What I need to do is to append the number of records that get pulled in from a table and increment the voucherNumber field to the next available one.
The code below was originally written in DAO.
Any help would be MUCH appreciated.
Thanks.
Jeff
What I need to do is to append the number of records that get pulled in from a table and increment the voucherNumber field to the next available one.
The code below was originally written in DAO.
Code:
Dim RecordCount As Integer
Dim strSQL As String
Dim db As Database
Dim rec As New ADODB.Recordset
Set db = CurrentDb
strSQL = "Select * from tblVoucherControl Where VoucherNumber is Null"
Set rec = New ADODB.Recordset
rec.Open rec, CurrentProject.Connection, adOpenDynamic, adLockOptimistic
rec.MoveFirst
RecordCount = 0
Do Until rec.EOF
rec.Edit
rec!VoucherNumber = DMax("voucherNumber", "tblVoucherControl") + 1
rec.Update
RecordCount = RecordCount + 1
rec.MoveNext
Loop
Thanks.
Jeff
Comment