Word 2000 - Visual Basic Runtime error '3008'

V

VBA Coder

In Word 2000 using DAO 3.6:

I am getting the following error

"Visual Basic Runtime error '3008': The table 'Test' is already opened
exclusively by another user, or it is already open through the user
interface and cannot be manipulated programmatically"

when I try to open my recordset object against a table in an Access database
where the table is open in the Access Database (MDB) in design mode. I do
not get the error if the table is open showing all the records - only if it
is open in Design mode.

Does anyone know if it is possible to run a SQL statement to return records
against a table that is open in Design Mode?

The following code is being executed against a table in an Access database
that is open in Design mode:

Dim wrkJet As DAO.Workspace
Dim db As Database
Dim rst As Recordset
Dim sSQL As String

Set wrkJet = CreateWorkspace("", "admin", "", dbUseJet)
Set db = wrkJet.OpenDatabase("C:\Test.mdb", , True)
sSQL = "SELECT * FROM Test"
Set rst = db.OpenRecordset(sSQL, dbOpenDynaset, dbReadOnly)
 
P

Perry

Replace
Dim db As Database
Dim rst As Recordset
by
Dim db As DAO.Database
Dim rst As DAO.Recordset

From Office 2K on, declare DAO objects explicitely pointing to the
DAO library, like examplified.

Kindly repost if this doesn't fix it.

Krgrds,
Perry
 
V

VBA Coder

Sorry, it still does not work. My updated code from your suggestion is
below. It fails on the OpenRecordset line:

Dim wrkJet As DAO.Workspace
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim sSQL As String

Set wrkJet = CreateWorkspace("", "admin", "", dbUseJet)
Set db = wrkJet.OpenDatabase("C:\Test.mdb", , True)
sSQL = "SELECT * FROM test"
Set rst = db.OpenRecordset(sSQL, dbOpenDynaset, dbReadOnly)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top