Copying Data from Access HELP

kb24gunner10

New Member
Joined
Sep 29, 2014
Messages
9
Hi,

I'm having trouble copying data from Access into excel. I have the following code:

Option Explicit
Dim RecordSet2 As ADODB.RecordSet, ExternalAccessTable2 As ADODB.Connection

Sub testcode()

Set ExternalAccessTable2 = New ADODB.Connection
Set RecordSet2 = New ADODB.RecordSet
ExternalAccessTable2.ConnectionString = "Provider=Microsoft.Ace.OLEDB.12.0; Data Source=C:\Users
\kb24gunner10\Desktop\OMIS3670GroupProjectDatabase.accdb;"
ExternalAccessTable2.Open


With RecordSet2
.ActiveConnection = ExternalAccessTable2
.Source = "SELECT Amount FROM CostExposures WHERE Magazine = 'A' AND Description = 'Exposures'"
.LockType = adLockReadOnly
.CursorType = adOpenForwardOnly
.Open
End With

Range("C5").CopyFromRecordset RecordSet2

RecordSet2.Close
ExternalAccessTable2.Close


End Sub


It gives me a run time error saying "No value given to one or more required parameters" and highlights the .open line of code.

Does anyone know the fix to this problem?

Thanks
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.

Forum statistics

Threads
1,223,719
Messages
6,174,089
Members
452,542
Latest member
Bricklin

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