error retreving data from access to excel

TCM1770

Board Regular
Joined
Feb 6, 2005
Messages
114
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
 

Some videos you may like

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off

TCM1770

Board Regular
Joined
Feb 6, 2005
Messages
114
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
 

Watch MrExcel Video

Forum statistics

Threads
1,114,573
Messages
5,548,853
Members
410,880
Latest member
LBrand
Top