Question : Item not found in collection

I keep getting an item not found in this collection error. I'm trying to transfer five fields of all the records of one table, into a table that has those same exact five fields. I think I may have a syntax error

Private Sub Command0_Click()
    Dim strSQL As String, rec As DAO.Recordset, cnn
    strSQL = "SELECT SN, PN, Description, [Module Number], [Module Type] FROM RXBoardTransfer"
    Set rec = CurrentDb.OpenRecordset(strSQL)
    Set cnn = CurrentProject.Connection
    Do Until rec.EOF
        strSQL = "INSERT INTO TransferTest SN, PN, Description, [Module Number], [Module Type] VALUES " & rec(SN) & "," & rec(PN) & "," & rec(Description) & "," & rec([Module Number]) & "," & rec([Module Type])
        cnn.Execute strSQL
        rec.MoveNext
    Loop
    Set rec = Nothing
    Set cnn = Nothing
    rec.close
    cnn.close
End Sub

Answer : Item not found in collection

try this codes
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
Private Sub Command0_Click()
    Dim strSQL As String, rec As DAO.Recordset, rs As DAO.Recordset
    Set rs = CurrentDb.OpenRecordset("TransferTest")
    strSQL = "SELECT SN, PN, Description, [Module Number], [Module Type] FROM RXBoardTransfer"
    Set rec = CurrentDb.OpenRecordset(strSQL)
    Do Until rec.EOF
        With rs
            .AddNew
            !SN = rec!SN
            !PN = rec!PN
            ![Description] = rec![Description]
            ![Module Number] = rec![Module Number]
            ![Module Type] = rec![Module Type]
            .Update
        End With
 
        rec.MoveNext
    Loop
    rec.Close
    rs.Close
    Set rec = Nothing
    Set rs = Nothing
    
End Sub
Random Solutions  
 
programming4us programming4us