multi-user question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a split database with users that log queries into the same table. For
the primary key I have a "dmax" code to add 1 to the highest number.

If two people add queries, one of them may not be accepted because of a
duplicate ID number.

I have seen the "refresh rate" in the options. If I lower the number will it
reduce the possibility of unaccepted records?

Cheers
 
Nope, but you can save the record immediately
ie

Private Sub GetID()

On Error Goto ErrDup

Get_ID:
VBA.Err.Clear
Me.ID.Value = Nz(DMax("ID",MyTable"),0) +1
Me.Dirty = False
Exit Sub

ErrDup:
Resume Get_ID ' should check for the actual err, but ..
End Sub

HTH

Pieter
 
thanks for the reply.

How does that code work?

Pieter Wijnen said:
Nope, but you can save the record immediately
ie

Private Sub GetID()

On Error Goto ErrDup

Get_ID:
VBA.Err.Clear
Me.ID.Value = Nz(DMax("ID",MyTable"),0) +1
Me.Dirty = False
Exit Sub

ErrDup:
Resume Get_ID ' should check for the actual err, but ..
End Sub

HTH

Pieter
 
Probably like yours, except that I save the record by using Me.Dirty =
False (simmilar to DoCmd.RunCommand acCmdSaveRecord)
If the save fails - somebody else is doing it at the same time & I retry
till I succeed.

Pieter
 
I have written a question on "short time" format in the query section (first
in the list).

Maybe you can help me with that?
 
This sample database shows a way to increment the number in a multi-user
environment.
http://www.rogersaccesslibrary.com/download3.asp?SampleName=AutonumberProblem.mdb

I used a custom function AssignNumber to create an incrementing number. It
includes letters, so it is a text field. I call the AssignNumber function
at the first opportunity, and assign the result to a string variable. In
the form's Before Update event I run the function again, and compare the
result to the string variable. If they are the same, all is well. If not,
the new value from the function becomes the value for the incrementing
field. To be safe, I assign the new result to the string variable, and run
the Before Update comparison again, just in case in that second or two
somebody cuts in on the line again.
 
In case I have not been clear, the sample database and the method I
described are two different things.
 
scubadiver said:
I have a split database with users that log queries into the same
table. For the primary key I have a "dmax" code to add 1 to the
highest number.

If two people add queries, one of them may not be accepted because of
a duplicate ID number.

I have seen the "refresh rate" in the options. If I lower the number
will it reduce the possibility of unaccepted records?

Cheers

What event are you using to make the DMax() calculation and assignment in?
The BeforeUpdate event is the only one that is reliable in a multi-user
environment.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Multi Access Database - Forms 2
If a record doesn't exist 12
DMAX with Criteria 1
Max Value In Query 4
New Record 8
Autonumber trying to create duplicates 3
Help with code 3
Multi-user access 2

Back
Top