A family of Microsoft relational database management systems designed for ease of use.
As you have no unique key, the only method is to loop the records and update the sequence number as you go. This works:
Public Function FillSequence()
Dim Records As DAO.Recordset
Dim Sql As String
Dim LastBatch As String
Dim ThisBatch As String
Dim LastSequence As String
Dim ThisSequence As String
Sql = "SELECT * FROM Batch ORDER BY Batch_Num, Abs([Seq_Num] Is Null), Seq_Num;"
Set Records = CurrentDb.OpenRecordset(Sql)
While Not Records.EOF
ThisBatch = Records!Batch_Num.Value
If LastBatch <> ThisBatch Then
LastBatch = ThisBatch
' Reset sequence.
LastSequence = "000"
End If
If Not IsNull(Records!Seq_Num.Value) Then
' Old batch.
LastSequence = Records!Seq_Num.Value
Else
' New batch.
ThisSequence = Format(Val(LastSequence) + 1, "000")
Records.Edit
Records!Seq_Num.Value = ThisSequence
Records.Update
LastSequence = ThisSequence
End If
Records.MoveNext
Wend
Records.Close
End Function