VBA - Open Connection Error

  • Thread starter Thread starter travis_5579
  • Start date Start date
T

travis_5579

Hi ,

I have encounter an issue state that
"-2147467259 (80004005)
The database has been placed in a place by user 'Admin'
on machine 'Travis Notebook' that prevent it from
being opened or locked "

I encounter this error when I try to open the access
database using the following code using VBA.

Public Sub OpenCon()
Set Con = New ADODB.Connection
Con.ConnectionString = Connection
Con.Provider = "Microsoft.Jet.OLEDB.4.0"
Con.Open "D:\Personal\KMS\KMS.mdb", "Admin"
End Sub

Hope some one will help me up.
 
Travis,

And I'll bet it doesn't throw the error the first time the procedure is
run - only on subsequent executions.

Change your code as follows:

Public Sub OpenCon()
Set Con = New ADODB.Connection
Con.ConnectionString = Connection
Con.Provider = "Microsoft.Jet.OLEDB.4.0"
Con.Open "D:\Personal\KMS\KMS.mdb", "Admin"
Con.Close
Set Con = Nothing
End Sub

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

Microsoft Access 2003 VBA Programmer's Reference
http://www.wiley.com/WileyCDA/WileyTitle/productCd-0764559036.html
 
Back
Top