Updating Field value from Field with same name

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
 
G

Guest

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top