Recordset Problem - object is closed

D

DBAL

Hey everyone,
I have used two different methods for creating a
recordset for this project and can't figure out why I
keep getting this error when trying to access the
recordcount or fields.count: '3704' Operation is not
allowed when the object is closed.

I TRIED THE OPEN METHOD:
'Create Recordset SLFCT1
Dim rstSLFCT1 As New Recordset
Set rstSLFCT1.ActiveConnection = conSQLSERVERConnection
rstSLFCT1.Open strSQL1, , adOpenStatic, adLockReadOnly,
adCmdText
rstSLFCT1.CursorLocation = adUseClient

'Determine Record Count
IntSLFCT1RowNum = rstSLFCT1.RecordCount

MsgBox "Record Count is " & IntSLFCT1RowNum


AND I TRIED THE CONNECTION OBJECT:
'Create RecordsetSLFCT1
Dim rstSLFCT1 As New Recordset

rstSLFCT1.CursorType = adOpenStatic
rstSLFCT1.LockType = adLockReadOnly
rstSLFCT1.CursorLocation = adUseClient
Set rstSLFCT1 = conSQLSERVERConnection.Execute(strSQL1)

'Determine Record Count
IntSLFCT1RowNum = rstSLFCT1.RecordCount

MsgBox "Record Count is " & IntSLFCT1RowNum


Both are returning this error. It says that the object
is closed? This same exact code as the second method has
has worked for me on a prior report, but with the error
saying object closed I tried the Open method with to no
avail.

The only thing different is that my strSQL1 string which
holds my query, holds a much more sophisticated query
with declared variables and IF BEGIN Blocks and such???

I can't figure this out, please advise

DBAL.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top