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