D
Dustin Pedroia
while using an Access 2007 .accdb file I can access the dao. object very
easily.
the following code in VBA works well :
Function getrecordcount(strTableName As String) As Long
Dim dbCurrent As DAO.Database
Set db = CurrentDb
Dim rstRecords As DAO.Recordset
Dim rstRecords2 As DAO.Recordset2
Set rstRecords = db.OpenRecordset(strTableName, dbOpenForwardOnly)
all the DAO.xxx references are recognized and are generated from the
Microsoft Office 12.0 Access database engine Object Library, acedao.dll
as evidenced by the ability to reference Recordset2.
but when similar code is generated in Visual Basic 2005 I am unable to
access the dao. object library using the same dao. naming conventions. for
some reason it forces me to use Microsoft.Office.Interop.Access.Dao.xxx in
every statement instead of just dao.
similar code in Visual Basic 2005 is :
Function getrecordcount(ByVal strTableName As String) As Long
Dim dbEngine As Microsoft.Office.Interop.Access.Dao.DBEngine
Dim db As Microsoft.Office.Interop.Access.Dao.Database
dbEngine = New Microsoft.Office.Interop.Access.Dao.DBEngine()
db = dbEngine.OpenDatabase("filename.accdb")
Dim rstRecords As Microsoft.Office.Interop.Access.Dao.Recordset
Dim rstRecords2 As Microsoft.Office.Interop.Access.Dao.Recordset2
rstRecords = db.OpenRecordset("strTableName", dbOpenForwardOnly)
rstRecords2 = db.OpenRecordset("strTableName", dbOpenForwardOnly)
and dbOpenForwardOnly generates a compile error of "is not declared"
while
Microsoft.Office.Interop.Access.Dao.RecordsetTypeEnum.dbOpenForwardOnly works
perfectly.
any ideas why dao. naming convention don't work ?
and why constants like dbOpenForwardOnly don't work ?
and why long naming like
Microsoft.Office.Interop.Access.Dao.RecordsetTypeEnum.dbOpenForwardOnly
is required ?
thanks
I do have the Microsoft Office 12.0 Access database engine Object Libary
added in Visual Basic 2005.
in VBA this object libary is located as c:\Program Files\Common
Files\Microsoft Shared\Acedao.dll
in VB 2005 it has a path of
c:\windows\assembly\GAC\Microsoft.Office.Interop.Access.Dao\12.0.0.__71e9bce111e9429c\Microsoft.Office.Interop.Access.Dao.dll
easily.
the following code in VBA works well :
Function getrecordcount(strTableName As String) As Long
Dim dbCurrent As DAO.Database
Set db = CurrentDb
Dim rstRecords As DAO.Recordset
Dim rstRecords2 As DAO.Recordset2
Set rstRecords = db.OpenRecordset(strTableName, dbOpenForwardOnly)
all the DAO.xxx references are recognized and are generated from the
Microsoft Office 12.0 Access database engine Object Library, acedao.dll
as evidenced by the ability to reference Recordset2.
but when similar code is generated in Visual Basic 2005 I am unable to
access the dao. object library using the same dao. naming conventions. for
some reason it forces me to use Microsoft.Office.Interop.Access.Dao.xxx in
every statement instead of just dao.
similar code in Visual Basic 2005 is :
Function getrecordcount(ByVal strTableName As String) As Long
Dim dbEngine As Microsoft.Office.Interop.Access.Dao.DBEngine
Dim db As Microsoft.Office.Interop.Access.Dao.Database
dbEngine = New Microsoft.Office.Interop.Access.Dao.DBEngine()
db = dbEngine.OpenDatabase("filename.accdb")
Dim rstRecords As Microsoft.Office.Interop.Access.Dao.Recordset
Dim rstRecords2 As Microsoft.Office.Interop.Access.Dao.Recordset2
rstRecords = db.OpenRecordset("strTableName", dbOpenForwardOnly)
rstRecords2 = db.OpenRecordset("strTableName", dbOpenForwardOnly)
and dbOpenForwardOnly generates a compile error of "is not declared"
while
Microsoft.Office.Interop.Access.Dao.RecordsetTypeEnum.dbOpenForwardOnly works
perfectly.
any ideas why dao. naming convention don't work ?
and why constants like dbOpenForwardOnly don't work ?
and why long naming like
Microsoft.Office.Interop.Access.Dao.RecordsetTypeEnum.dbOpenForwardOnly
is required ?
thanks
I do have the Microsoft Office 12.0 Access database engine Object Libary
added in Visual Basic 2005.
in VBA this object libary is located as c:\Program Files\Common
Files\Microsoft Shared\Acedao.dll
in VB 2005 it has a path of
c:\windows\assembly\GAC\Microsoft.Office.Interop.Access.Dao\12.0.0.__71e9bce111e9429c\Microsoft.Office.Interop.Access.Dao.dll