What is supposed to be a rather elementary piece of code is beginning to become a huge problem for me.
I have been coding an ActiveX control, with a TreeView control, to manipulate a disconnected ADO recordset (name rsMenu). I also have a class module (within the same project) that needs to reference that recordset.
It seems that I can pass the recordset to the class just fine, but when I try to actually USE the recordset (i.e. the .movefirst method) I get a "Object or with block variable not set".
In my activeX control I have setup the recordset as follows.
Private dbCONN as ADODB.Connection
Private rsMenu as ADODB.Recordset
Private cmdMenu as ADODB.Command
Set dbCONN = New ADODB.Connection
Set rsMenu = New ADODB.Recordset
Set cmdMenu = New ADODB.Command
dbCONN.ConnectionString = "Driver={SQL Server};" & _
"Server=Starweb;" & _
"Uid=usr_starnet;" & _
"Pwd=usr_starnet;" & _
"Database=Starnet;"
dbCONN.Open
cmdMenu.ActiveConnection = dbCONN
cmdMenu.CommandTimeout = 600
cmdMenu.CommandText = "select * from menu order by linkid "
cmdMenu.CommandType = 1 'adCmdText
rsMenu.LockType = adLockBatchOptimistic
rsMenu.CursorLocation = adUseClient
rsMenu.CursorType = adOpenStatic
rsMenu.Open cmdMenu
rsMenu.ActiveConnection = Nothing
rsMenu.MarshalOptions = adMarshalModifiedOnly
... then I instantiate my class later in my code with ...
Dim SourceInfo as NodeInfo
Set SourceInfo = New NodeInfo
SourceInfo.Reference = rsMenu
... my class is defined as follows (simplistic)...
Private m_rsReference as ADODB.Recordset
Public Property Let Reference(blah as ADODB.Recordset)
Set m_rsReference = blah
End Property
Apparently, the recordset is being passed to the class module correctly, but something happens to it in the passing because I get that horrific "Object variable or with block variable not set" error when trying to do any operations on it. Like the following...
If TypeName(m_rsReference)<>"Recordset" Then
Exit Sub
Else
m_rsReference.MoveFirst <--- Offending line of code.
End If
--This seems like such an elementary problem can someone help me resolve this?
I have been coding an ActiveX control, with a TreeView control, to manipulate a disconnected ADO recordset (name rsMenu). I also have a class module (within the same project) that needs to reference that recordset.
It seems that I can pass the recordset to the class just fine, but when I try to actually USE the recordset (i.e. the .movefirst method) I get a "Object or with block variable not set".
In my activeX control I have setup the recordset as follows.
Private dbCONN as ADODB.Connection
Private rsMenu as ADODB.Recordset
Private cmdMenu as ADODB.Command
Set dbCONN = New ADODB.Connection
Set rsMenu = New ADODB.Recordset
Set cmdMenu = New ADODB.Command
dbCONN.ConnectionString = "Driver={SQL Server};" & _
"Server=Starweb;" & _
"Uid=usr_starnet;" & _
"Pwd=usr_starnet;" & _
"Database=Starnet;"
dbCONN.Open
cmdMenu.ActiveConnection = dbCONN
cmdMenu.CommandTimeout = 600
cmdMenu.CommandText = "select * from menu order by linkid "
cmdMenu.CommandType = 1 'adCmdText
rsMenu.LockType = adLockBatchOptimistic
rsMenu.CursorLocation = adUseClient
rsMenu.CursorType = adOpenStatic
rsMenu.Open cmdMenu
rsMenu.ActiveConnection = Nothing
rsMenu.MarshalOptions = adMarshalModifiedOnly
... then I instantiate my class later in my code with ...
Dim SourceInfo as NodeInfo
Set SourceInfo = New NodeInfo
SourceInfo.Reference = rsMenu
... my class is defined as follows (simplistic)...
Private m_rsReference as ADODB.Recordset
Public Property Let Reference(blah as ADODB.Recordset)
Set m_rsReference = blah
End Property
Apparently, the recordset is being passed to the class module correctly, but something happens to it in the passing because I get that horrific "Object variable or with block variable not set" error when trying to do any operations on it. Like the following...
If TypeName(m_rsReference)<>"Recordset" Then
Exit Sub
Else
m_rsReference.MoveFirst <--- Offending line of code.
End If
--This seems like such an elementary problem can someone help me resolve this?