I need to add data to a table using a function in a module. I have tried defining the table as a Recordset as follows:
Dim rstMain As Recordset
Set rstMain = CurrentDb.OpenRecordset("tblMain"
With rstMain
.AddNew
!Field1 = "New Data"
!Field2 = "More New Data"
End With
rstMain.Close
but i get an error "Type Mismatch" on the line "Set rstMain..."
What am i doing wrong and how can i get round it? Any advice gratefully received,
Rob
Dim rstMain As Recordset
Set rstMain = CurrentDb.OpenRecordset("tblMain"
With rstMain
.AddNew
!Field1 = "New Data"
!Field2 = "More New Data"
End With
rstMain.Close
but i get an error "Type Mismatch" on the line "Set rstMain..."
What am i doing wrong and how can i get round it? Any advice gratefully received,
Rob