Dim rsz As Recordset
Dim rst As Recordset
DoCmd.SetWarnings False
Set rsz = CurrentDb.OpenRecordset("SELECT * FROM amphoe WHERE dolacode<>amp_code")
Do While Not rsz.EOF
amp_code = rsz.Fields("amp_code")
dolacode = rsz.Fields("dolacode")
DoCmd.RunSQL "UPDATE EPE0 set ADDRCODE=Replace(ADDRCODE, '" & dolacode & "', '" & amp_code & "',1,4) WHERE left(ADDRCODE,4)='" & dolacode & "'"
rsz.MoveNext
Loop
End Function