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