I have the following code in a class module
This opens fine and loads the Datagrid
In the program on a new form I want to reOpen the Rs Recordset
I tried the following code
but I get error 91 can you help please
Code:
vb6
Public Sub Class_Initialize()
'connect to the Database and open up the Database Table.
dbPath = "D:\Program Files\Microsoft Visual Studio\VB98\Ron Files\Pension\"
Set strConn = New ADODB.Connection
strConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dbPath & "Pension.mdb"
strConn.CursorLocation = adUseClient
'Set and define your command
strQuery = "SELECT * FROM Pension " & _
" ORDER BY Year,LastName,FirstName"
'Set and Define RecordSet
With frmTest
.adoControl.ConnectionString = strConn
.adoControl.RecordSource = strQuery
Set .dgControl.DataSource = .adoControl
End With
Set Rs = New ADODB.Recordset
With Rs
Set .ActiveConnection = strConn
.CursorType = adOpenStatic
.Source = strQuery
.Open
End With
With frmTest.dgControl
strsName = "" & .Columns(0)
strfName = "" & .Columns(1)
strmName = "" & .Columns(2)
strPens1 = "" & .Columns(3)
strPens2 = "" & .Columns(7)
End With
'Clean up after you have finished
Rs.Close
Set Rs = Nothing
strConn.Close
Set strConn = Nothing
End Sub
In the program on a new form I want to reOpen the Rs Recordset
I tried the following code
Code:
vb6
Dim Rs As ADODB.Recordset
Titles.Rs.Open Titles.strQuery, Titles.strConn, adOpenStatic
Titles.Rs.MoveFirst