connection object

Code the General Declarations section as shown below. Here, two ADO objects, ADODB.Connection andADODB.Recordset, are defined at the form level.

The ADODB.Connection object represents an open connection to a data source and a specific database on that data source, or an allocated but as yet unconnected object, which can be used to subsequently establish a connection.

The ADODB.Recordset object represents the rows that result from running a query,

Option Explicit

Dim mobjADOConn As ADODB.Connection
Dim mobjADORst As ADODB.Recordset
Dim mstrSQL As String