error retreving data from access to excel

TCM1770

Board Regular
Joined
Feb 6, 2005
Messages
121
Office Version
  1. 365
not sure why I am getting this error: no value given for one or more required parameters.
Here is my code - can anyone point me in the right direction?

Sub GetRecords()

Dim cnn As ADODB.Connection
Dim RST As ADODB.Recordset
Dim WSOrig As Worksheet
Dim WSTemp As Worksheet
Dim sSQL As String
Dim finalrow As Long


Set WSOrig = ActiveSheet

'build the sql string to det all fields for unsent transfers

sSQL = "SELECT QuoteDate, InsdsName, LName, CurrentCarrier, EffectiveDate, QuoteProposal, AUTO, HOME, UMBRELLA, WORK_COMP, BOP, FIRE_DWELLING, TERM, CLUE, MVR, NOTES FROM Quote1"
sSQL = sSQL & " WHERE Sent=FALSE"

'path to transfer.accdb

Myconn = "C:\Users\Theresa\Desktop\1QuoteS1.accdb"

Set cnn = New ADODB.Connection

With cnn
.Provider = "Microsoft.ACE.OLEDB.12.0" ' Data Source=c:\users\Theresa\Desktop\1QuoteS1.accdb"
.Open Myconn

End With

Set RST = New ADODB.Recordset
RST.CursorLocation = adUseServer
RST.Open Source:=sSQL, ActiveConnection:=cnn, CursorType:=AdForwardOnly, LockType:=adLockOptimistic, Options:=adCmdText

'create the report in a new worksheet
Set WSTemp = Worksheet.Add

' add headings
Range("A1:P1").Value = Array("QuoteDate", "InsdsName", "LName", "CurrentCarrier", "EffectiveDate", "QuoteProposal", "AUTO", "HOME", "UMBRELLA", "WORK_COMP", "BOP", "FIRE_DWELLING", "TERM", "CLUE", "MVR", "NOTES")

'Copy from the recordset to row 5
Range("A2").CopyFromRecordset RST
'close the connection
RST.Close
cnn.Close

'format the report

finalrow = Range("a10000").End(xlUp).Row

'if there were no records, then stop
If finalrow = 1 Then

Application.DisplayAlerts = False
WSTemp.Delete
Application.DisplayAlerts = True
WSOrig.Activate
MsgBox "there are no transfers to confirm"
Exit Sub
End If
End Sub
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
this is interesting; however, I have no experience coding or building expressions in access. I have no clue how to begin the spreadsheet transfer. Thank you for the response I will have to do a lot more research before I attempt it.

TM
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,771
Members
452,353
Latest member
strainu

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