First Back Up your data, then try this code
Function UpdateTable()
Dim MyDB As DAO.Database, MyRec As DAO.Recordset
Dim MyCount As Integer, OldValue As String
OldValue = ""
Set MyDB = CurrentDb
Set MyRec = MyDB.OpenRecordset("Select ID from TableName Order By ID")
While Not MyRec.EOF
If OldValue = MyRec!ID Then
MyCount = MyCount + 1
Else
MyCount = 1
End If
OldValue = MyRec!ID
MyRec.Edit
MyRec!ID = MyRec!ID & Format(MyCount, "00")
MyRec.Update
MyRec.MoveNext
Wend
End Function

Signature
Good Luck
BS"D
> Hi,
>
[quoted text clipped - 22 lines]
> Many thanks.
> Nils
Nils Pettersson - 03 Jul 2007 10:24 GMT
Thanks Ofer. This worked just as well. This information will prove very useful.
> First Back Up your data, then try this code
>
[quoted text clipped - 45 lines]
> > Many thanks.
> > Nils
If you can guarantee that the Name field is unique then you could try
UPDATE YourTable
SET ID = ID & DCount("ID","YourTable","ID=""" & [ID] & """ AND [Name] <="""
& [Name] &"""")
Alternative with a limited number of duplicated ids might be to repeat the
query below changing the 1 to 2, 3, 4, etc.
UPDATE YourTable
SET ID = [Id] & "1"
WHERE
(SELECT Count([Name])
FROM YourTable as YT
WHERE YT.ID = YourTable.ID and YT.Name <=YourTable.Name) = 1
AND YourTable.ID Not Like "*#"
<<< add the last criteria to only update records that do not end in a
number>>> hopefully keeping you from updating records that have already been
updated.
AS always, back up your data FIRST. There is no going back

Signature
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
.
> Hi,
>
[quoted text clipped - 24 lines]
> Many thanks.
> Nils
Nils Pettersson - 03 Jul 2007 10:22 GMT
Thank you so much John! I've been trying so hard to get the right logic for
this to work in a query. It's been a thorn on my side for so long!
> If you can guarantee that the Name field is unique then you could try
>
[quoted text clipped - 46 lines]
> > Many thanks.
> > Nils