Results 1 to 3 of 3

Thread: Record locking

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 1999
    Location
    NSW,Australia
    Posts
    34
    what i need to do is, when a record is displayed on a form and then the user wants to edit the record, i need to lock the record so no other users can edit the record at the same time. I am using the latest version of ADO.
    Has anyone got some ideas for the best way to handle this situation.

    Thanks
    Simon

  2. #2
    Hyperactive Member
    Join Date
    Jul 2002
    Location
    Canada
    Posts
    455

    Wink

    Hello kisijo,

    You don't have any problem if you change the database record on the form.

    You have to write code to update.

    (1)
    Set ProjectsDB = ProjectsWS.OpenDatabase("YourDatabase.mdb")
    Set CustomerDYN = ProjectsDB.OpenRecordset("select * from YourTable")


    CustomerDYN.Edit 'new information for existing record


    CustomerDYN!Yourfield1 = text1.text
    CustomerDYN!Yourfield2 = text2.text
    CustomerDYN!Yourfield3 = text3.text

    CustomerDYN.Update 'now the records will be updated!!


    (2)
    if you want to prevent editing the record in the form: place all textboxes in a frame. With enabling/disabling you can protect the information on the form

    (3)
    an Other possibility is protecting with the event:

    Private Sub Text1_KeyPress(KeyAscii As Integer)
    KeyAscii = 0
    End Sub

    When you will do this, it is handy to create a control array. VB will ask you when you are copy and paste a part of the form.
    On such a way all TextBoxes in the control array are using the same event code!

    Good luck,

    Michelle.

    [Edited by michelle on 04-12-2000 at 03:50 AM]

  3. #3

    Thread Starter
    Member
    Join Date
    Sep 1999
    Location
    NSW,Australia
    Posts
    34
    Thanks Michelle, what if the other users are on there own pc's, and dont know if the record is about to be edited. Can the record be locked in this case so they can not edit the same record, as one person will loose changes to that record.

Posting Permissions

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



Click Here to Expand Forum to Full Width