Results 1 to 3 of 3

Thread: Locking tables in MS Access

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2000
    Location
    Slovenia, Europe
    Posts
    58
    I have this a transaction that goes like this:

    Dim rst1 As Recordset
    Dim rst2 As Recordset
    Dim MaxID, i

    wspc.BeginTrans

    Set rst1 = dbs.OpenRecordset("SELECT Max(ID) FROM Table1")
    tbl.MoveFirst
    MaxID = tbl.Fields(0)
    rst1.Close

    Set rst1 = dbs.OpenRecordset("Table1")
    Set rst2 = dbs.OpenRecordset("Table2")

    For i = 1 To numberOfEntries
    rst1.AddNew
    rst1.Fields("ID") = MaxID + i
    '.
    '.
    rst1.Update

    rst2.AddNew
    '.
    '.
    rst2.Fields("ID_Table1") = MaxID + i
    rst2.Update
    Next i
    rst1.Close
    rst2.Close

    wspc.CommitTrans

    I would like to disable other users to read from or write to both Table1 and Table2 (lock them) while the transaction is active.
    If anyone knows how to do this than please answer.

    Thanx

    Tadej

  2. #2
    Guest

    Ok don't have vb on this machine.....but

    Look at the mdb Exclusive property. If set to true then only the person with the mdb open and get access to it.

    Something Like

    Dim dbStuff as Database

    dBStuff = OpenDatabase(whatever)

    dbStuff.Exclusive = True

    Will have a look back at the office and get back to ya on it.

  3. #3

    Thread Starter
    Member
    Join Date
    Jun 2000
    Location
    Slovenia, Europe
    Posts
    58
    Thank you, but I dont want to open the database
    exclusively because I want to allow other users to
    access other tables in the database.
    I only want to restrict access to those two tables.

    Tadej

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