Methods DAOPrivDBEngine

The unsupported PrivDBEngine object enables you to connect to an external database that uses a different Workgroup Information File to the one currently being used. You can open an Access database without having to create another instance of Access. PrivDBEngine only allows access to DAO objects, such as TableDefs, QueryDefs, Recordsets, Fields, Containers, Documents, Indexes, and Relations.

Dim dbX As PrivDBEngine Dim wsX As Workspace Dim dbe As Database

'Return a reference to a new instance of the PrivDBEngine object Set dbe = New PrivDBEngine

'Set the SystemDB property to specify the workgroup file dbe.SystemDB = strWIFPath

'Specify the username (this could be any valid username) dbe.DefaultUser = strUserName

'Specify the password dbe.DefaultPassword = strPassword

'Set the workspace

Set wsX = dbe.Workspaces(O)

'Open the secured database

Set dbe = ws.OpenDatabase(strDBPath)

The PrivDBEngine object does nothing more than create a new instance of the Access database engine. You can get the same functionality by doing the following:

Dim dbe As DAO.DBEngine

Set dbe = CreateObject("DAO.DBEngine")

The following table lists the CreateObject argument for different versions of the Jet or Access database engine.

Jet/Access Version

Argument

Example

3.0

DAO.DBEngine

Set dbe = CreateObject(

'DAO

DBEngine")

3.5

DAO.DBEngine.35

Set dbe = CreateObject(

'DAO

DBEngine.35")

3.6

DAO.DBEngine.36

Set dbe = CreateObject(

'DAO

DBEngine.36")

12.0

DAO.DBEngine.120

Set dbe = CreateObject(

'DAO

DBEngine.120")

Recordset.Collect

The DAO Recordset and Recordset2 objects expose a hidden, undocumented property named Collect. Although Collect is a property, it behaves like the Recordset object's Fields collection, but it's faster because it doesn't need a reference to the Field object. Be aware that Recordset.Collect only returns a field's value; it doesn't expose any other properties. You can use this property by passing it a numeric item number, or a field name, just like the Fields collection. For example:

Set rs = db.OpenRecordset("tblCustomers")

Debug.Print "CustID: " & rs.Collect(O)

Debug.Print "CustomerNo: " & rs.Collect("CustomerNo")

Recordset.Parent

The undocumented Recordset.Parent property is an object reference to the database to which the recordset belongs. This may be especially useful in situations where you have several Database objects in the same application.

0 0

Post a comment

  • Receive news updates via email from this site