ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Error Opening Access Table in VBA (https://www.excelbanter.com/excel-programming/386146-error-opening-access-table-vba.html)

Charles in Iraq

Error Opening Access Table in VBA
 
Greetings:

I have the following VBA code attempting to open
a table in my ACCESS database:

Sub GetLast30()
Dim wksp As DAO.Workspace
Dim dbs As DAO.Database
Dim rst1 As DAO.Recordset
Dim rng As Range

Set wksp = DAO.CreateWorkspace("wksp", "admin", "", dbUseJet)
Set dbs = wksp.OpenDatabase("TASS Alarms.mdb")
Set rst1 = dbs.OpenRecordset("tblAlarmsCook")

Charles in Iraq

Error Opening Access Table in VBA
 
The program worked after I provided a full path.

Thanks for your help.

Charles

"JLatham" wrote:

I just copied your code and changed nothing but the path/filename for a .mdb
file on my system and a table name within it and had no trouble accessing the
fields in the table.

#1 - check that the database is in the current directory, or provide a full
path to the .mdp file when you use the .OpenDatabase command.

Check in Excel VBEditor to make sure you have Tools | References set to both
the Microsoft Access Library and to the DAO 3.6 Object library.

"Charles in Iraq" wrote:

Greetings:

I have the following VBA code attempting to open
a table in my ACCESS database:

Sub GetLast30()
Dim wksp As DAO.Workspace
Dim dbs As DAO.Database
Dim rst1 As DAO.Recordset
Dim rng As Range

Set wksp = DAO.CreateWorkspace("wksp", "admin", "", dbUseJet)
Set dbs = wksp.OpenDatabase("TASS Alarms.mdb")
Set rst1 = dbs.OpenRecordset("tblAlarmsCook")
.
.
.
End Sub

But when I attempt the run this code, I get the following error:

Run-time error '3078':

The Microsoft Jet dtabase engine cannot find the input table or query
'tblAlarmsCook'. Make sure it exists and that its name is spelled
correctly.

Needless to say, this table definitely exists and its name is spelled
correctly. So why am I getting this error? Is there some other
property I need to set to correctly open this table?

Regards,

Charles


JLatham

Error Opening Access Table in VBA
 
I just copied your code and changed nothing but the path/filename for a .mdb
file on my system and a table name within it and had no trouble accessing the
fields in the table.

#1 - check that the database is in the current directory, or provide a full
path to the .mdp file when you use the .OpenDatabase command.

Check in Excel VBEditor to make sure you have Tools | References set to both
the Microsoft Access Library and to the DAO 3.6 Object library.

"Charles in Iraq" wrote:

Greetings:

I have the following VBA code attempting to open
a table in my ACCESS database:

Sub GetLast30()
Dim wksp As DAO.Workspace
Dim dbs As DAO.Database
Dim rst1 As DAO.Recordset
Dim rng As Range

Set wksp = DAO.CreateWorkspace("wksp", "admin", "", dbUseJet)
Set dbs = wksp.OpenDatabase("TASS Alarms.mdb")
Set rst1 = dbs.OpenRecordset("tblAlarmsCook")
.
.
.
End Sub

But when I attempt the run this code, I get the following error:

Run-time error '3078':

The Microsoft Jet dtabase engine cannot find the input table or query
'tblAlarmsCook'. Make sure it exists and that its name is spelled
correctly.

Needless to say, this table definitely exists and its name is spelled
correctly. So why am I getting this error? Is there some other
property I need to set to correctly open this table?

Regards,

Charles


JLatham

Error Opening Access Table in VBA
 
You're welcome. Glad it turned out to be that easy. The devil is in the
details.

"Charles in Iraq" wrote:

The program worked after I provided a full path.

Thanks for your help.

Charles

"JLatham" wrote:

I just copied your code and changed nothing but the path/filename for a .mdb
file on my system and a table name within it and had no trouble accessing the
fields in the table.

#1 - check that the database is in the current directory, or provide a full
path to the .mdp file when you use the .OpenDatabase command.

Check in Excel VBEditor to make sure you have Tools | References set to both
the Microsoft Access Library and to the DAO 3.6 Object library.

"Charles in Iraq" wrote:

Greetings:

I have the following VBA code attempting to open
a table in my ACCESS database:

Sub GetLast30()
Dim wksp As DAO.Workspace
Dim dbs As DAO.Database
Dim rst1 As DAO.Recordset
Dim rng As Range

Set wksp = DAO.CreateWorkspace("wksp", "admin", "", dbUseJet)
Set dbs = wksp.OpenDatabase("TASS Alarms.mdb")
Set rst1 = dbs.OpenRecordset("tblAlarmsCook")
.
.
.
End Sub

But when I attempt the run this code, I get the following error:

Run-time error '3078':

The Microsoft Jet dtabase engine cannot find the input table or query
'tblAlarmsCook'. Make sure it exists and that its name is spelled
correctly.

Needless to say, this table definitely exists and its name is spelled
correctly. So why am I getting this error? Is there some other
property I need to set to correctly open this table?

Regards,

Charles



All times are GMT +1. The time now is 11:59 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com