UnsolvedCoding
Technical User
Hey all,
I have code that runs SQL from Excel but on several different locations when the recordset is opened the code errors out. It keeps telling me its not open. I have tried a couple of different formats (listed below) to get around this but it keeps coming up.
Set rsDB = New ADODB.Recordset
rsDB.CursorLocation = adUseClient
rsDB.Open sSQL, cnDB, 3, 1, 1
Set rsDB = New ADODB.Recordset
rsDB.ActiveConnection = cnDB
rsDB.CursorLocation = adUseClient
rsDB.Open sSQL, cnDB, 3, 1, 1
The other problem is I am having extreme difficulty in getting the recordset to go to a cell location. I have tried
ThisWorkbook.Sheets("Cover").Range("J" & i) = rsDB("REASON")
and
Range("J" & i) = rsDB("REASON")
and
Activecell.value = rsDB("REASON")
And
Activecell.offset(0,3).value = rsDB("REASON")
I'm stumped.
I have code that runs SQL from Excel but on several different locations when the recordset is opened the code errors out. It keeps telling me its not open. I have tried a couple of different formats (listed below) to get around this but it keeps coming up.
Set rsDB = New ADODB.Recordset
rsDB.CursorLocation = adUseClient
rsDB.Open sSQL, cnDB, 3, 1, 1
Set rsDB = New ADODB.Recordset
rsDB.ActiveConnection = cnDB
rsDB.CursorLocation = adUseClient
rsDB.Open sSQL, cnDB, 3, 1, 1
The other problem is I am having extreme difficulty in getting the recordset to go to a cell location. I have tried
ThisWorkbook.Sheets("Cover").Range("J" & i) = rsDB("REASON")
and
Range("J" & i) = rsDB("REASON")
and
Activecell.value = rsDB("REASON")
And
Activecell.offset(0,3).value = rsDB("REASON")
I'm stumped.