looping query

67flyer

Registered User.
Local time
Yesterday, 19:23
Joined
Jul 29, 2006
Messages
49
I am trying to add another record to a table. Pid and nsn are the keys. the table has 70 unique pid's. I need to add another nsn to each of the pid's. I tried the following code but no go:

Set db = CurrentDb
Set rst1 = db.OpenRecordset("tblHandReceipt")
Set rst2 = db.OpenRecordset("tblHandReceipt")

rst1.MoveFirst
Do Until rst1.EOF
rst2.AddNew
rst2!PID = rst1!PID
rst2!NSN = Forms!frmparts!NSN
rst2!ISSUEDSOURCE = Forms!frmparts!subfrmEndItemParts.Form!cbxENDITEM
'Add like above line for each field
rst2.Update
rst2.MoveNext
rst1.MoveNext
Loop
rst1.Close
rst2.Close

Thanks for any help.
 
The data is normalized in tblPids and in tblNSN. tblhandreceipt is a combined table that contains combinations of pid's and nsn's. Not every pid in tblpids is in tblhandreceipt. I wanted to add another nsn to tblhandreceipt but I only want to add it to the pids that are already in tblhandreceipt.
 
why not make a select query joining the two tables together, and use that as the source rst for your procedure. then you definitley just get the matches without having to try to synchronize two recordsets
 

Users who are viewing this thread

Back
Top Bottom