I am facing "Unspecified error" in only one PC of my users.
Run-time error '-2147467259 (80004005)':
Unspecified error
I am running the below VBA code to open a connection to Access database located in network shared drive. But the code throws the error whenever it is trying to run the .Open
statement.
I thought it is a driver issue and installed Access 2007 Database engine in the user's PC and replaced Provider with "Microsoft.ACE.OLEDB.12.0
" but it doesn't work.
Code:
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim retVal As Boolean
Dim strSQL As String
retVal = False
On Error GoTo CatchError
Set cn = New ADODB.Connection
With cn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.Properties("Jet OLEDB:Database Password") = Initialize.GetDBPwd 'returns pass
.Open Initialize.GetDbConnectionString 'returns the network DB path
End With
I have the same issue while making an ADODB connection from a local Excel file to another local Excel file.
The only way how I solve it is re-opening the main Excel file from which I do the connection. Nothing else done, and the function works again.
My connection function:
Sub SetConReadOnly(ByRef con1 As Object, ByRef rst1 As Object, sFile As String)
If con1 Is Nothing Then Set con1 = CreateObject("ADODB.Connection")
If rst1 Is Nothing Then Set rst1 = CreateObject("ADODB.Recordset")
con1.Open "Provider=Microsoft.ACE.OLEDB.12.0;" & _
"Data Source=" & sFile & ";" & _
"Extended Properties=""Excel 12.0;HDR=No;IMEX=1;"""
End Sub
(I use Office 2013 32-bit, Windows 7 64-bit)