The Active Connection Property

Prior to opening the Recordset object, you can use the ActiveConnection property to assign an existing Connection object to the Recordset or a connection string for the recordset to use to connect to the database. If you assign a connection string, the recordset will create a Connection object for itself. Once the recordset has been opened, this property returns an object reference to the Connection object being used by the recordset.

The following code assigns a Connection object to the ActiveConnection property:

Set rsData.ActiveConnection = objConn

The following code assigns a connection string to the ActiveConnection property:

rsData.ActiveConnection = "Provider=Microsoft.ACE.OLEDB.12.0;" & _

"Data Source=C:\Files\Northwind 2007.accdb"

0 0

Post a comment