PDA

View Full Version : Solved: Create New Record in Access from Excel Macro



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

Ischyros
12-07-2009, 11:18 AM
Okay so I guess my post was premature. I figured out the problem from microsoft support. Its poste below.

"If your project contains references to both the Data Access Objects (DAO) library and the ActiveX Data Objects (ADO) library, you may see multiple Recordset entries in the list when you dimension the Recordset object. This error occurs when you list the ADO library with a higher priority than the DAO library in the References dialog box, regardless of which Recordset entry you select from the list. "