DB Connection error in Access

P

Paul Vencill

I was trying to create a table programmatically in an
Access 2002 module. I am just learning this, so I used a
code snippet from a VBA coursebook that looks like this:

Sub CreateTable()
Const ProviderStr = "C:\$User\db.mdb"
Const ConnectionStr
= "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +
ProviderStr

Dim Table As New Table
Dim catalog As New ADOX.catalog
Dim Key As New ADOX.Key
catalog.ActiveConnection = ConnectionStr

I get a runtime error on the last line there, which states:

'The database has been placed in a state by user (my
username) on machine (my machinename) that prevents it
from being opened or locked'

I am the administrator for the DB, the default opening of
the DB is 'shared', and I've not done any overt action to
open it exclusively (though I wouldn't think any of that
would matter, given that I'm the admin, and it's open in
my name). No other users are on the DB that I'm working
with.

Ideas?
 

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