After you open the database in shared mode, you can implement recordset locking by specifying various constants in the options argument of the OpenRecordset method. You can combine options to more completely describe the type of locking you want to use.
Û To open a Recordset with locking enabled
For example, the following code opens the Orders table exclusively by combining the dbDenyWrite and the dbDenyRead constants in the options argument.
Function OpenTableExclusive(strDbPath As String, _ strRstSource As String) As Recordset Dim dbs As Database Dim rst As Recordset ' Open the database in shared mode by calling the ' OpenDatabaseShared function defined in preceding section. Set dbs = OpenDatabaseShared(strDbPath) ' Open table exclusively. If Not dbs Is Nothing Then Set rst = dbs.OpenRecordset(strRstSource, _ dbOpenTable, dbDenyRead + dbDenyWrite) If Not rst Is Nothing Then Set OpenTableExclusive = rst Else Set OpenTableExclusive = Nothing End If Else Set OpenTableExclusive = Nothing End If End Function
Note If you open a Recordset object without specifying any value for the options argument, Microsoft Jet uses page locking by default. The Recordset is opened in shared mode; it does not lock other users out of its data, and locks only the data being edited in the current page.
See Also For more information about opening a recordset, see “Creating a Recordset Variable” in Chapter 5, “Working with Records and Fields” and search the DAO Help index for “OpenRecordset method.”