How to solve Runtime error 3704 in visual basic 6.0

vb6

I am getting Runtime 3704 Operation is not allowed when the object is closed error Please help me to solve this error, my code is –

Private Sub Form_Load()
Ado.ConnectionString = ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & (App.Path & "\Test.mdb") & ";Persist Security Info=False;")
    Ado.RecordSource = "select * from Emp"
    Ado.Refresh
Call RSRun("select EmpName from Emp")
lst.Clear
lst.AddItem ("All")
While RS.EOF = False
lst.AddItem (RS.Fields(0).Value)
RS.MoveNext
Wend
End Sub

Im modules

Public Sub RSRun(ByVal SqlStr As String)
   On Error GoTo Er
    Set RS = Nothing
RS.Open SqlStr, Conn, adOpenDynamic, adLockOptimistic

Exit Sub
Er:
MsgBox Err.Description, vbCritical, "error-" & Err.Number
End Sub

Thanks,
Yugal

Best Answer

Where is Conn defined and could it be closed at the point when RS.Open... is called?

Related Topic