opening a connection

  • Thread starter Thread starter Dave B
  • Start date Start date
D

Dave B

I have a VBA module that works with data in my database, but for some reason
it doesn't work anymore. The code is:

Set cnRebate = New ADODB.Connection
Set tblIssuers = New ADODB.Recordset

cnRebate.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\My Documents\Rebate.mdb;"
cnRebate.Open
tblIssuers.Open "Issuers", cnRebate, adOpenKeyset, adLockOptimistic
tblIssuers.MoveFirst

When executing the line "cnRebate.Open" I get the error: "Run-time error
'-2147467259 (80004005)': The database has been placed in a state by user
"Admin" on machine "Chedda" that prevents it from being opened or locked."

I created this database from scratch on my PC, so I assume "Admin" is me or
my operating system. This code worked before, but now it doesn't. Could
some property of the database have changed without my knowledge which locks
the database? Does it matter that the module is stored in the same database
I'm trying to connect to? Thanks.

Dave
 
If the module is stored in the same database you are trying to connect to,
there is an easier way of making the connection that might (although of
course it also might not, try it and see) solve your problem:

Set cnRebate = CurrentProject.Connection

HTH

Adam
 
Back
Top