Discussion Locked

Multi User Functionality

0 helpful
7 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

We have been developing multi user applications using VB as front end and MS-Access as back End.

In each of the transaction modules(s), the system generates a serial number for a transaction (by referring to a control table and adding 1 to the last transaction number of the transaction type).But when these transactions are executed by more then one users simultaneously at the same instant of time, the same number is generated by the system instead it should have generated a different transaction number for each of the user (or terminal).
how to achieve this using VB/ACCESS ?

7 replies

by rob wolfe

You have run into the classic problem of multiple updates to a database object.

MS support site has an example that does the lock checking for you at the following URL
http://support.microsoft.com/support/kb/articles/Q106/5/35.asp

What you have to do is to integrate that logic so that each of the users picks up their own copy of the transaction #. now it is possible that you might then end up with gaps in your transaction # but that is avoidable with a little work and planning

Happy trails

by francodacosta

have you considered opening the rcordset with the
* dbSeeChanges option witch generates a run-time error if one user is changing data that another user is editing.
* dbDenyWrite option witch prevents other users from modifying or adding records.* dbDenyRead option witch prevents other users from reading data in a table.
(assuming you are using DAO)

you can allways use an GUID generator to generate an unique number for the transaction

Hope this was helpfull.

Fell free to contact me if you still have problems.

by bob sellman

If the numbers don't have to be sequential with no gaps, then an autonumber field for the serial number would do the job, especially if you were just starting.

Alternately, the process of determining the next number should be to read the current max value from the control table (which I'm assuming is a table with one record holding the value of the highest control number), and IMMEDIATELY increment the value by one in the control table.

When you do this will determine if you have any gapsin the numbers. If you don't assign the number until you save the added transaction data, then you probably won't have any gaps. However, if you have transactions that have a header table and a related detail table that are related by the transaction number (the serial number you mention), then you must have the serial number before you can add detail data. In that case, if someone is adding data and then decides to trash the transaction, the number will never be used.

Unless it's really critical to have no gaps, I would use this method. (The autonumber is easier, but since you already have numbers assigned, I'm sure you don't want to renumber the transactions.) While there is a very brief exposure to the same number, you should beable to set up the code so the incrementing occurs quickly or even in one step before you read it.

This discussion is closed to new replies.