Elana
Registered User.
- Local time
- Today, 09:11
- Joined
- Apr 19, 2000
- Messages
- 232
Here is my code to add records to a table based on records shown on a subform.
Problem: This will only add records if I open the form and run the code on the first record. If I move to another record in the form and attempt to run the code, it will not add records to the table, BUT, If I close the form, reopen it, move to any record and then run the code, it will work.
Why does it only work on the first attempt after opening the form. Advice Please!
Thanks Elana
Dim dbs As Database
Dim rst As Recordset
Dim rst1 As Recordset
Set dbs = CurrentDb()
Set rst = Forms!frmClaimsEntry!frmPolicyUwrsSubform.Form.RecordsetClone
Set rst1 = dbs.OpenRecordset("tblUwrByClaim")
Do Until rst.EOF
rst1.AddNew
rst1!ClaimID = Forms!frmClaimsEntry!ClaimID
rst1!SUwrID = rst!SUwrID
rst1.Update
rst.MoveNext
Loop
rst.Close
rst1.Close
Problem: This will only add records if I open the form and run the code on the first record. If I move to another record in the form and attempt to run the code, it will not add records to the table, BUT, If I close the form, reopen it, move to any record and then run the code, it will work.
Why does it only work on the first attempt after opening the form. Advice Please!
Thanks Elana
Dim dbs As Database
Dim rst As Recordset
Dim rst1 As Recordset
Set dbs = CurrentDb()
Set rst = Forms!frmClaimsEntry!frmPolicyUwrsSubform.Form.RecordsetClone
Set rst1 = dbs.OpenRecordset("tblUwrByClaim")
Do Until rst.EOF
rst1.AddNew
rst1!ClaimID = Forms!frmClaimsEntry!ClaimID
rst1!SUwrID = rst!SUwrID
rst1.Update
rst.MoveNext
Loop
rst.Close
rst1.Close