Assume your table is called tbl_Data and the fields are exactly what you have listed paste this code into a module and run it:
Code:
Dim db As Database
Dim rst As Recordset
Dim sSQL As String
Dim sCurrNames As String
Dim sPrevNames As String
Dim iNamesCount As Integer
Dim iRecCount As Integer
Set db = CurrentDb
sSQL = "SELECT * FROM tbl_Data ORDER BY NAMES, PK"
Set rst = db.OpenRecordset(sSQL)
rst.MoveFirst
iNamesCount = 1
iRecCount = 0
rst.Edit
rst.Fields("col1").Value = iNamesCount
rst.Fields("col2").Value = iRecCount
rst.Update
sPrevNames = rst.Fields("names")
rst.MoveNext
Do While rst.EOF <> True
sCurrNames = rst.Fields("names").Value
If sCurrNames = sPrevNames Then
iRecCount = iRecCount + 1
rst.Edit
rst.Fields("col1").Value = iNamesCount
rst.Fields("col2").Value = iRecCount
rst.Update
Else
iRecCount = 0
iNamesCount = iNamesCount + 1
rst.Edit
rst.Fields("col1").Value = iNamesCount
rst.Fields("col2").Value = iRecCount
rst.Update
End If
sPrevNames = sCurrNames
rst.MoveNext
Loop