Ischyros
12-07-2009, 10:24 AM
I am trying to add a new record to access from excel. There is a workbook that manages projects, and when the user selects new project I want to create a new record in access. My code is below. I get a run-tim 13 "Type mismatch" error on the following line
Set rs = db.OpenRecordset("Capital_Projects", dbOpenTable)
CODE:
Dim FileType As String
Dim AccessFile As Variant
Dim db As Database
Dim rs As Recordset
Dim R As Long
AccessFile = "I:\Afe\Accounting\Project Database\TRPDData.mdb"
Set db = OpenDatabase(AccessFile)
Set rs = db.OpenRecordset("Capital_Projects", dbOpenTable)
With rs
.AddNew 'Create a new record
End With
rs.Close
Set rs = Nothing
db.Close
Set db = Nothing
'MsgBox "Complete"
End Sub
Set rs = db.OpenRecordset("Capital_Projects", dbOpenTable)
CODE:
Dim FileType As String
Dim AccessFile As Variant
Dim db As Database
Dim rs As Recordset
Dim R As Long
AccessFile = "I:\Afe\Accounting\Project Database\TRPDData.mdb"
Set db = OpenDatabase(AccessFile)
Set rs = db.OpenRecordset("Capital_Projects", dbOpenTable)
With rs
.AddNew 'Create a new record
End With
rs.Close
Set rs = Nothing
db.Close
Set db = Nothing
'MsgBox "Complete"
End Sub