Results 1 to 5 of 5
  1. #1
    Join Date
    Nov 2002
    Location
    Sacramento, CA
    Posts
    34

    Question Unanswered: Display Record Locking Info

    I'm have a access 97 db. I would like to be able to display, on a form, if a record is already locked by another user, and if possible, the user that has it locked.

    Anyone know how to do this??

  2. #2
    Join Date
    Nov 2002
    Location
    San Francisco
    Posts
    251
    you can use this simple code... (change the recordset and connection string). It works only if one user makes changes to the form and is still on that record.... then the other can use this code.... you can put it ON CURRENT event on the form....


    Dim myConnection As String
    Dim myRecset As New ADODB.Recordset

    On Error Resume Next

    'replace this connection string with
    'currentproject.connection for Access2000
    myConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    "Data Source=c:\winnt\desktop\Db1.mdb;" & _
    "User Id=admin;" & _
    "Password="

    myRecset.Open "SELECT * FROM myTable WHERE myId = 3", myConnection, adOpenDynamic, adLockPessimistic
    myRecset.Fields(2) = myRecset.Fields(2)
    If Err.Number = -2147467259 Then
    MsgBox "This field is LOCKED!!"
    End If
    myRecset.Close



    jiri


  3. #3
    Join Date
    Nov 2002
    Location
    Sacramento, CA
    Posts
    34
    Will this work in 97?
    Im getting an error, "User defined type not defined" on
    Dim myRecset As New ADODB.Recordset
    Do I need to add a Reference?
    Last edited by dragracer; 02-27-03 at 12:18.

  4. #4
    Join Date
    Oct 2002
    Location
    Leicester - UK
    Posts
    820
    Originally posted by dragracer
    Will this work in 97?
    Im getting an error, "User defined type not defined" on
    Dim myRecset As New ADODB.Recordset
    Do I need to add a Reference?
    it should work as long as you've got the ado library referenced
    Definition of a Beginner, Someone who doesn't know the rules.

    Definition of an Expert, Someone who knows when to ignore the rules.

  5. #5
    Join Date
    Nov 2002
    Location
    Sacramento, CA
    Posts
    34
    Got it. Had the wrong lib ref'ed

    Thanks
    Make the money, don't let the money make you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •