Run Time Error 3706 - Excel 2007/Access 2007

davidb88

Board Regular
Joined
Sep 23, 2013
Messages
76
I would like to be able to open a connection between an Excel 2007 file and an Access 2007 file to bring in a table from an already established Access database. I know that to do so, you need certain references enabled in VBA but I am not sure which ones I need. I suspect that is why I get a runtime error 3706 when I try to run the following code. Can anyone point me in the right direction of which references need to enabled in order to connect Excel 2007 to Access 2007?

Code:
sub macro1(control As IRibbonControl)
 
Dim cnn As ADODB.Connection
Dim rs As ADODB.Connection
Dim sQRY As String
Dim strFilePath As String
 
    strFilePath = "H:\Tracker Database\Database.accdb"
    Set cnn = New ADODB.Connection
    Set rs = New ADODB.Connection
    cnn.Open "Provider=Microsoft.Jet.OLEDB.12.0;" & _
        "Data Source=" & strFilePath & ";"
    sQRY = "SELECT tblclstrack.*FROM tblclstrack"
    rs.CursorLocation = adUseClient
    rs.Open sQRY, cnn, adOpenStatic, adLockReadOnly
    Application.ScreenUpdating = False
    Sheet1.Range("B2").CopyFromRecordset rs
    rs.Close
    Set rs = Nothing
    cnn.Close
    Set cnn = Nothing
    Exit Sub
 
End Sub
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
I was able to figure it out. It was in the connection string. Should have been:
Code:
cnn.Open "Provider=Microsoft.Ace.OLEDB.120.0;" & _
       "Data Source=" & strFilePath & ";"

However I am now getting a runtime error 3001: Arguments of the wrong type, are out of acceptable range, or are in conflict with one another.

Does anyone have any idea what that means?
 
Upvote 0

Forum statistics

Threads
1,213,554
Messages
6,114,280
Members
448,562
Latest member
Flashbond

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top