Updating Field value from Field with same name

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Would like to update the value in Tbl_AddNew.NamesAdd with the value from
Tbl_Double.NamesAdd (I really do not want to have a different field name in
each table).

I thought code below would work but it does not!!

Any help much appreciated.

Set rst = _
DB.OpenRecordset("SELECT Tbl_Double.NamesAdd, Tbl_AddNew.NamesAdd
FROM Tbl_Double INNER JOIN Tbl_AddNew ON Tbl_Double.NamesAdd_ID =
Tbl_AddNew.NamesAdd_ID ORDER BY Tbl_AddNew.NamesAdd_ID;")

With rst
Do While Not rst.EOF

.Edit

!Tbl_AddNew.NamesAdd = !Tbl_Double.NamesAdd


.Update
.MoveNext
Loop
 
Instead of looping through each record in the table, why don't you just
execute a query to do it all for you? Something like

DoCmd.SetWarnings False 'Turns off prompts
DoCmd.RunSQL "UPDATE Tbl_AddNew SET Tbl_AddNew.NamesAdd =
Tbl_Double.NamesAdd WHERE Tbl_Double.NamesAdd_ID = Tbl_AddNew.NamesAdd_ID "
DoCmd.SetWarnings True

It is much more efficient.
 
Back
Top