Generally it should be a good idea to Declare ADODB objects in Module.
As connection is needed all throug the program, this could also be SET and opened in the Module itself.
Similarly the adoRS could be Declared & SET in the Module.
But the adoRS would be prefarably be Opened whenever reqd.
Here Iam using an illustration declaring at Form level
Code:
'Declarations
Dim adoRS As ADODB.Recordset
Dim adoCONN As ADODB.Connection
Private Sub Form_Load()
Set adoCONN = New ADODB.Connection
' Have code to initialize connection string
Set adoRS = New ADODB.Recordset
Call DoSomething
End Sub
Private Sub DoSomething()
' Have some code to open & close recordset
End Sub
by Opening the adoRS whenever reqd we have an oppurtunity to reuse the adoRS.
At form unload the adoRS should be checked if open and closed. It should be SET to nothing when the prog closes.
The connection should necessarily be closed & SET to nothing when prog ends.