View Single Post
Old March 8th, 2006, 08:17 PM
adam_kahtava adam_kahtava is offline
Wrox Technical Editor
Join Date: Dec 2005
Location: , , Canada.
Posts: 271
Thanks: 0
Thanked 0 Times in 0 Posts

Here's part of an example using Pessimistic locking at the Record-Level.

Private Sub CmdModify_Click()
    'Set the Query String
    SQL = "Select * from Individual where IndividualID=24"

    'Re-set the Recordset variable
    Set RsModIndividual = New ADODB.Recordset

    'Open the Query into the Recordset
    RsModIndividual.Open SQL, dbrms, adOpenKeyset, adLockPessimistic, adCmdText

    Dim RecordDate As String 'Variable to store a Field data.

    'Here we are transferring one Field value named LastUpdated into a string variable
    RecordDate = RsModIndividual![LastUpdated] 'Transferring Last Updated Field value

    If Check_Record_Status(RecordDate) Then 'Call the Record lock function
        Load FrmModIndividual 'Load the Modification Form
        MsgBox "Try Editing after a while ", vbInformation, "Record Locked by User"
        Exit Sub
    End If

End Sub

Code taken from:

- A.Kahtava