Last Record

  • Thread starter Thread starter David W
  • Start date Start date
D

David W

Got a problem

I thought I was doing good with this, guess not.

I am using;

Me.po = DMax("po", "po") + 1

to get the last PO Number generated.
It works well as long as someone else is not creating a PO at the time
(multiple user enviroment).

How do I need to go about getting a value from a table that is being used
with record locking?
 
How do I lock thee?
Let me count the ways.

There are two basic approaches I can think of.
One is to immediately create a new record with the calculated PO number so
that another user would then get the next number. The drawback is that if
you decide not to complete the PO, you have an unused number. You would
still have to use error handling to allow for the off chance that user 1
retrieved the next number milliseconds before user 2 created the new record.
That would involve requerying for the MAX and doing it again.
The other is similar in that you retrieve the next PO number, complete your
data entry, then in the Before Update event of your form, check to see if the
number has been used. If it has, then get another number and notify the user.
 
What I ended up doing was to go to the next record after updating the first
control in order to lock the number
 
That would work, but then don't you have to go back to it to complete
entering the data?
 
Back
Top