As mentioned, you could probably get what you need done using an action query to append your records. You could use the Query Builder to get your SQL and then copy your SQL to be used behind your form. You can manage errors using dbFailOnError. So you will want to add some code in case there is a problem.
https://msdn.microsoft.com/en-us/lib.../ff197654.aspx
Code:
Dim strSQL As String
strSQL = "SQL copied from Query Builder"
CurrentDb.Execute strSQL, dbFailOnError
DAO is a great tool and is very useful when you need control of things. Your case may not need DAO. But, it is good to look at it and understand it. It may open doors to great ideas.
Here is some code from one of my DB's. It sits behind an unbound form to update a table. This code Appends one record.
Code:
Dim rcdAddPO As DAO.Recordset
Set rcdAddPO = db.OpenRecordset("tblPurchOrd", dbOpenDynaset)
With rcdAddPO
.AddNew
![CustFK] = lngCustID
![SoldToFK] = lngSoldTo
![EnterUnit] = -1 'Let the program know we will be adding units and pieces
![EnterPieces] = -1 'be adding units and pieces
![PlantFK] = lngPlantID
![PO] = strPO
![CarNum] = strCarNum
![Shipment] = strShipment
![ShipDate] = dtShipDate
![SalesOrder] = strSalesOrder
![Lading] = strLading
lngPurchOrd = ![PurchOrdPK] 'Get the PK to place in FK later
.Update
End With
If you were to implement DAO in your case, you would have to open two recordsets. One recordset would be iterated and the second would append. You would have to nest them.
It would probably look something like this.
Code:
'Create a query with WHERE criteria
Dim strSQL As String
strSQL = "SELECT BatchID, ScriptNumber, InvoiceID, Ignore " & _
"FROM QuUninvoicedScripts " & _
"WHERE ((InvoiceID) is null) AND Ignore=false"
'Open the new query so we can loop through it
Dim rcdAppendInvoice As DAO.Recordset
Dim db As DAO.Database
Set db = CurrentDb
Set rcdAppendInvoice = db.OpenRecordset(strSQL, dbOpenDynaset)
'Make sure we have some records
rcdAppendInvoice.MoveFirst
If rcdAppendInvoice.EOF = True Then
'TODO add some error trapping here
End If
'Open up a recordset for the table to append to
Dim rcdAddPO As DAO.Recordset
Set rcdAddPO = db.OpenRecordset("tblInvoices", dbOpenDynaset)
'loop through our records that need to be appended
While rcdAppendInvoice.EOF = False
With rcdAddPO
.AddNew
![CustFK] = rcdAppendInvoice![BatchID]
![SoldToFK] = lrcdAppendInvoice![ScriptNumber]
![MyDateField] = Date 'Setting default value at table level is probably better
.Update
End With
rcdAppendInvoice.MoveNext
Wend 'rcdAppendInvoice.EOF = False
'Tidy up
rcdAddPO.Close
Set rcdAddPO = Nothing
rcdAppendInvoice.Close
Set rcdAppendInvoice = Nothing