ronakj16
02-10-2019, 12:23 PM
Hi,
I am just a beginner and trying below VBA Code-
Public Sub DAOTest()
Dim myRecordset As dao.Recordset
Dim myDatabase As dao.Database
myDatabase = DBEngine("C:\temp\Northwind.accdb")
'Create the DAO-style Recordset
myRecordset = myDatabase.OpenRecordset(Name:="Customers", Type:=dbOpenTable)
MsgBox(myRecordset("ID"))
MsgBox(myRecordset("Company"))
End Sub
but it is Throwing 2 error-
Error 1 Name 'DBEngine' is not declared.
Error 2 Name 'dbOpenTable' is not declared.
Need help to solve this 'DAO' related issue. I am using VB2008 and MS Office 2007 and i have also included DAO under VBA Reference.
I am just a beginner and trying below VBA Code-
Public Sub DAOTest()
Dim myRecordset As dao.Recordset
Dim myDatabase As dao.Database
myDatabase = DBEngine("C:\temp\Northwind.accdb")
'Create the DAO-style Recordset
myRecordset = myDatabase.OpenRecordset(Name:="Customers", Type:=dbOpenTable)
MsgBox(myRecordset("ID"))
MsgBox(myRecordset("Company"))
End Sub
but it is Throwing 2 error-
Error 1 Name 'DBEngine' is not declared.
Error 2 Name 'dbOpenTable' is not declared.
Need help to solve this 'DAO' related issue. I am using VB2008 and MS Office 2007 and i have also included DAO under VBA Reference.