Hi Tony,
This is an infinite loop.
Do Until tbl2.EOF
tbl2.AddNew
tbl2![PersonID] = vPersonID
tbl2.Update
tbl2.MoveNext
Loop
Even if your code could enter it, it could never exit. vPersonID will be added to the [PersonID] field ad infinitum, provided [PersonID] is not your Master table's primary key field. If it is, your code will throw Run-time error 3022 when you try and create a duplicate primary key value.
The loop will be entered, however, if some records already exist in the Master table when the loop is reached. A recordset will be created that includes records already in the table, and vPersonID will just keep getting appended to the end of that recordset. If the master table is empty when the loop is reached, then:
Set tbl2 = DB.OpenRecordset("Master")
will create an empty recordset, which means tbl2.EOF is already TRUE, which means:
Do Until tbl2.EOF
will never execute.
HTH,
Bob
|