J
JP
i new to write a number in each key field like '01' '02'...the code below
works but starts with the last record, it should start with the first record
in the temporary table.
Private Sub Command9_Click()
' write the line number for each po line
Dim count, cycles, linecount As String
cycles = 0 'how many loops
count = 0 ' number of records
linecount = "01" ' increment for line items
Dim dbs As Database, rst As Recordset
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("LineItems", dbOpenTable)
rst.MoveLast
rst.MoveFirst
count = rst.recordcount
Do Until cycles = count
With rst
.AddNew
![LineNum] = linecount
.update
rst.MoveNext
linecount = linecount + 1
cycles = cycles + 1
End With
Loop
rst.close
works but starts with the last record, it should start with the first record
in the temporary table.
Private Sub Command9_Click()
' write the line number for each po line
Dim count, cycles, linecount As String
cycles = 0 'how many loops
count = 0 ' number of records
linecount = "01" ' increment for line items
Dim dbs As Database, rst As Recordset
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("LineItems", dbOpenTable)
rst.MoveLast
rst.MoveFirst
count = rst.recordcount
Do Until cycles = count
With rst
.AddNew
![LineNum] = linecount
.update
rst.MoveNext
linecount = linecount + 1
cycles = cycles + 1
End With
Loop
rst.close