Using ADO Objects
ADO uses objects to access data and provide that to the user. If you are using the Microsoft ADO Data Control, then you don’t have to instantiate your connection and recordset objects. However, if you choose to create and dispose of connections and recordsets on-the-fly, you will need to instantiate and later destroy your objects. Furthermore, the current shipping version of the ADO Data Control will use ADO 2.1 functionality (such as Index support) only if you create the recordset through code and set the Recordset property of the ADO Data Control to this recordset in code (this may also involve changing your project references to include ADO 2.1 rather than the default ADO 2.0).
To instantiate an object, use the New keyword. On declaration of the object:
Dim cn as New ADODB.Connection
Dim rs as New ADODB.Recordset
Immediately before use:
Dim cn as ADODB.Connection
Dim rs as ADODB.Recordset
Set cn = New ADODB.Connection
Set rs = New ADODB.Connection
To dispose of those objects:
Set rs = Nothing
Set cn = Nothing