use optimictic lock to open recordset : Lock « Access « VBA / Excel / Access / Word






use optimictic lock to open recordset

 
Private Sub Form_Open(Cancel As Integer)

    Dim con As ADODB.Connection
    Dim myRecordset As ADODB.Recordset
    Dim strFrmNm As String
    
    Set myRecordset = New ADODB.Recordset
    Set con = New ADODB.Connection
    
    con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\store.mdb;"
       
    myRecordset.Open "SELECT * FROM Employees", con, adOpenKeyset, adLockOptimistic
    Set Me.Recordset = myRecordset
    
    myRecordset.Close
    con.Close
    Set myRecordset = Nothing
    Set con = Nothing

End Sub

 








Related examples in the same category

1.Use Row Level Locking
2.Default Record Locking
3.Set and get the lock type
4.Configuration of LockType as a Property of the Recordset Object
5.Set Lock Type to adLockOptimistic