bradyboyy88
Well-known Member
- Joined
- Feb 25, 2015
- Messages
- 562
I have a macro which uses the following connection string below. This works great on our 64bit windows 8.1 which is running 32bit excel and access (our database we connect to). However, we have some new laptops with windows 10 64bit and 32bit excel and access which it creates the 3706 provider not found error when trying to open the connection. I checked the common files folder and the oledb dll file is there. Any ideas?
Code:
Public Sub SQLOpenDatabaseConnection(StrDBPath As String, EngineType As Integer)
'Define Connection String by inputting StrDBPath into a larger string (Works for Excel DB)
'Define Connection String by inputting StrDBPath into a larger string
'Access Support for engine type
If EngineType = 0 Then
sConn = "Provider=Microsoft.ACE.OLEDB.15.0;" & _
"Data Source=" & StrDBPath & ";" & _
"Jet OLEDB:Engine Type=5;" & _
"Persist Security Info=False;Mode=Share Exclusive;"
'Excel Support for engine type
ElseIf EngineType = 1 Then
sConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source='" & StrDBPath & "';" & _
"Extended Properties=""Excel 12.0;HDR=NO;ReadOnly=0;"";"
End If
RetryConnection:
Sleep 100
DoEvents
On Error GoTo ErrorHandler
'Connect to the database
20 oConn.Open sConn
On Error GoTo 0
Exit Sub
ErrorHandler:
'triggered by connection error. Most likely locking type
'MsgBox "looks like we had a connection error. The error number is " & Err.Number & " and the description is " & Err.Description & " on line " & Erl
Err.Clear
Resume RetryConnection
End Sub