Using MS Access/Multi-user databases

Advertisement


Question
Hi Scott,
I have a question in regard to multi-user databases.  My database will be split with the back-end on the server and the front-end on each user's computer.  I have done this before and didn't have much issue.  The only issue that I am concerned about is a collision between two or more users.  The form that I am using has a sequential numbering system that seems to work perfectly (Thanks to your help!!) The user will open a form, choose a consignee number from a combo box, then choose the fiscal year from another combo just below it, then the user will click the command button to generate a new PO number.  I have placed the following code in the on click event of the button.  Should I have added anything further to ensure that an error won't appear in the case that two or more users click this button at exactly the same time.  Here is the code:

If IsNull(Me.TXTFCODE) Then
MsgBox "Please enter the appropriate consignee code.", vbOKOnly
Me.TXTFCODE.SetFocus

If IsNull(Me.TXTFYEAR) Then
MsgBox "Please enter the last two digits of the fiscal year.", vbOKOnly
Me.TXTFYEAR.SetFocus

Else
Me.TXTSEQUENCE = Nz(DMax("[SEQUENCE]", "[Purchase Details]", "[CONSIGNEE]= '" & Me.[TXTFCODE] & "'"), 0) + 1

Me.Dirty = False
End If
End If
Me.TXTSEQUENCE = Nz(DMax("[SEQUENCE]", "[PURCHASE DETAILS]", "[CONSIGNEE] = '" & Me.TXTFCODE & "'  AND [FYEAR] = '" & Me.TXTFYEAR & "'"), 0) + 1
Me.POID.Visible = True

Thanks so much for your help!!  I is greatly appreciated as always.  Carla  :)

Answer
I'm a little confused about why you are generating TXTSEQUENCE twice. If the sequence is based on the combination of Consignee and Fiscal Year, then you shouldn't be generating the number just on Consignee.


But to prevent the possibility of 2 users generating the same sequence, create a multi-field unique index on the combination of the three fields.

Hope this helps,
Scott<>

Using MS Access

All Answers


Answers by Expert:


Ask Experts

Volunteer


Scottgem

Expertise

I can answer almost all types of questions relating to Microsoft Access usage and application design. My strengths are database and interface design.

Experience

I've been designing databases for over 25 years working with dBase, FoxPro, Approach and Access.

Organizations
Author of Microsoft Office Access 2007 VBA
Techncial Editor for Special Edition Using Microsoft Access 2007 and Access 2007 Forms, Reports & Queries From Que Publishing

Education/Credentials
Brooklyn College BA

©2016 About.com. All rights reserved.