View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Charles in Iraq Charles in Iraq is offline
external usenet poster
 
Posts: 13
Default 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