VBA - Open Connection Error

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.
 
G

Graham R Seach

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
 

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