Good day! It takes my over an hour then I got an error message Run Time Error 3035 (System Resource Exceeded). Please see below code for your reference.

Dim rstT1 As Recordset
Dim rstUpdate As Recordset
Dim iMatching As String
Dim iT1, iT2 As Long
Dim iMatchNum As Long
Dim iMatchID As Long
Dim i As Long




CurrentDb.Execute ("UPDATE Table01 SET MatchNum = null")
CurrentDb.Execute ("UPDATE Table02 SET MatchNum = null")
Set rstT1 = CurrentDb.OpenRecordset("qryTable1Processing1")




Do While rstT1.EOF <> True
iMatching = rstT1!User_ID
iT1 = DCount("*", "Table01", "[User_ID] = '" & iMatching & "'")
iT2 = DCount("*", "Table02", "[Combine] = '" & iMatching & "'")
If iT1 > 0 And iT2 > 0 Then
If iT1 > iT2 Then
iMatchNum = iT2
Else
iMatchNum = iT1
End If

Debug.Print dDate & " " & iMatchNum
Set rstUpdate = CurrentDb.OpenRecordset("SELECT TOP " & iMatchNum & " MatchNum FROM Table01 WHERE [User_ID] = '" & iMatching & "'")
i = 0
Do While rstUpdate.EOF <> True


i = i + 1
rstUpdate.Edit
rstUpdate!matchnum = iMatchID + i
rstUpdate.Update
rstUpdate.MoveNext
Loop
rstUpdate.Close
Set rstUpdate = CurrentDb.OpenRecordset("SELECT TOP " & iMatchNum & " MatchNum FROM Table02 WHERE [Combine] = '" & iMatching & "'")
i = 0
Do While rstUpdate.EOF <> True
i = i + 1
rstUpdate.Edit
rstUpdate!matchnum = iMatchID + i
rstUpdate.Update
rstUpdate.MoveNext
Loop
rstUpdate.Close

Debug.Print "adding " & iMatchID & " to " & iMatchNum
iMatchID = iMatchID + iMatchNum
End If
rstT1.MoveNext
Loop
rstT1.Close
Set rstT1 = Nothing


End Sub