I tried a couple approaches to get it done on a query but was not successful in creating an updateable query. It seemed easier to me to use DAO and nest an updatable query within a loop. I would still create some queries and make sure that a plate number is not assigned two different personnel ID's and other possible referential/constraint issues.
So I ended up with the following. Not sure I got the names of the fields perfect but ...
Code:
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strPlate As String
Dim lngID As Long
Dim strSQL As String
Set db = CurrentDb
Set rs = db.OpenRecordset("SELECT DISTINCT Kenteken2, Pnummer FROM tblWaarschuwingen WHERE Pnummer IS NOT NULL", dbOpenSnapshot)
rs.MoveFirst
While rs.EOF = False
strSQL = ""
strPlate = rs![Kenteken2] 'Get the License Plate Number
lngID = rs![Pnummer] 'Get the Personnel ID
strSQL = "UPDATE tblWaarschuwingen SET Pnummer = " & lngID & " WHERE (((Kenteken2)='" & strPlate & "') AND Pnummer Is Null);"
db.Execute strSQL
rs.MoveNext
Wend
rs.Close
Set rs = Nothing
Set db = Nothing
MsgBox "Complete"