newprogamer
Programmer
Hello Everyone,
I am using VBA. I have created several excel spreadsheets. I would like to write the data from cells in excel to access database. I am using the code below. I keep getting a compile error. The program stops executing at the "Dim db as Database" statement. The error is "User-defined type not defined". Can anyone tell me what I need to do. Thanks!
NewProgrammer
'write to database
Dim db As Database
Dim Rs As Recordset
Set db = OpenDatabase("C:\Quotes\quote.mdb")
' open the database
Set Rs = db.OpenRecordset("FileName", dbOpenTable)
' Add a new record into the database
With Rs
.AddNew ' create a new record
' add values to each field in the record
Debug.Print strInitials
.Fields("QuotedBy") = strInitials
Debug.Print strDate
.Fields("Date") = strDate
End With
I am using VBA. I have created several excel spreadsheets. I would like to write the data from cells in excel to access database. I am using the code below. I keep getting a compile error. The program stops executing at the "Dim db as Database" statement. The error is "User-defined type not defined". Can anyone tell me what I need to do. Thanks!
NewProgrammer
'write to database
Dim db As Database
Dim Rs As Recordset
Set db = OpenDatabase("C:\Quotes\quote.mdb")
' open the database
Set Rs = db.OpenRecordset("FileName", dbOpenTable)
' Add a new record into the database
With Rs
.AddNew ' create a new record
' add values to each field in the record
Debug.Print strInitials
.Fields("QuotedBy") = strInitials
Debug.Print strDate
.Fields("Date") = strDate
End With