Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Multiuser / Networking / December 2004

Tip: Looking for answers? Try searching our database.

multiuser record locking in VBA ?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Rajesh B. Patel - 06 Dec 2004 22:53 GMT
Hi,

(I posted this question, but did not receive a response, perhaps I
should rephrase)

I do not want users to get execute the following code simultaneously.
That is, if user 1 is in the middle of this routine and adding records
from rstAddThese to rstToHere, then I do not want to let user 2 to do
the same:

-----------------------------

   Set db = CurrentDb()

   BeginTrans

   Set rstToHere = db.OpenRecordset("SELECT * FOR tbl_Blah...")
   Set rstAddThese = db.OpenRecordset("SELECT TOP 10 ID FROM qry_Blah")

   Do While Not rstAddThese.EOF
      rstToHere.AddNew

      rstToHere!ID = rstAddThese.Fields("ID")
      rstToHere!RA = CurrentUser()
      rstToHere.Update

      rstAddThese.MoveNext
   Loop

   CommitTrans

   rstAddThese.Close
   rstToHere.Close

   db.Close

-----------------------------

Does a VBA mechanism exist to accomplish this? The transaction does seem
to do the trick (unless I tested it incorrectly).

I cannot find one, nor can I find a solution on the newsgroups.

I have thought about creating a locks table in which each user
attempting this operation will write their username before continuing.
Each user will check if another user has written their username into the
table and wait until that record is removed to proceed. Is this a viable
alternative? Has anyone solved a problem such as this in a similar way?

Thank you in advance.

raj
Joan Wild - 08 Dec 2004 16:30 GMT
Check Help for the OpenRecordset method.
Set recordset = object.OpenRecordset (source, type, options, lockedits)

particularly the dbDenyRead/dbDenyWrite options

Signature

Joan Wild
Microsoft Access MVP

> Hi,
>
[quoted text clipped - 50 lines]
>
> raj
Rajesh B. Patel - 09 Dec 2004 00:37 GMT
Hi,

THanks for your reply.

I have investigated this; however, OpenRecordset with dbDenyRead does
not work with linked tables and my db is split.

Any other suggestions?

Thanks again.

raj

> Check Help for the OpenRecordset method.
>  Set recordset = object.OpenRecordset (source, type, options, lockedits)
>
> particularly the dbDenyRead/dbDenyWrite options
Joan Wild - 09 Dec 2004 19:59 GMT
You could open the backend directly via the OpenDatabase method and then you
could use the dbDenyRead on the table recordset.

> Hi,
>
[quoted text clipped - 14 lines]
>>
>> particularly the dbDenyRead/dbDenyWrite options

Signature

Joan Wild
Microsoft Access MVP

Rajesh B. Patel - 09 Dec 2004 20:12 GMT
Excellent! Thank you for your suggestion I will try it.

> You could open the backend directly via the OpenDatabase method and then you
> could use the dbDenyRead on the table recordset.
[quoted text clipped - 17 lines]
>>>
>>>particularly the dbDenyRead/dbDenyWrite options
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.