Help or advise on Record Locking

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

Guest

I'm going live with my DB tomorrow morning. I wanted to to Edited Records
for my lock type but ran into a problem, this weekend when I took it to our
office and had it on multiple computers for the first time. (I've been
designing at my house, in my spare time (right), so I couldn't test for the
problem I have now.) When a user is on a record and I open the same record
up on another computer it locks ok and shows in the Record Selector that it's
locked but if I begin to tab through the form I have at least one code that
pukes. In my LastName field, in the On Exit event, I have the following code:
If Not (IsNull(Me.LastName)) Then
Me.LastName = StrConv(Me.LastName, vbProperCase)
End If
As I try to Exit this field, only when the record is locked, the code pukes.
Can some one lend a hand and give some advise on how to prevent this?

Thanks ahead of time,
Shane
 
. In my LastName field, in the On Exit event, I have the following code:
If Not (IsNull(Me.LastName)) Then
Me.LastName = StrConv(Me.LastName, vbProperCase)
End If
As I try to Exit this field, only when the record is locked, the code
pukes.
Can some one lend a hand and give some advise on how to prevent this?

The exit event is the wrong event to use. Why have code run when the user
has done nothing? The above code as setup will ALWAYS run,a nd thus force
the user to dirty the record...and in effect cause a disk write.

The correct event for the above code is the controls AFTER UPDATE event. If
the user does not change the data, then the event does not fire.

Using the exit event is bad for code that needs to modify the users input,
since as you can just moving around with the cursor means the record will
get modified (dirtied) without the user actually changing anything. This
will result in all kinds of disk updates to occur when none are actually
needed, and in a multi user environment, not only does that create the
locking problem you have, but also wastes the VERY precious network to do
work when none is needed.

-
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
(e-mail address removed)
http://www.members.shaw.ca/AlbertKallal
 
Thanks for the help Albert. Also thank you very much for explaining why I
need to use the AfterUpdate. I don't do this for a living. My family and I
are in medical equipment sales and having a small family business makes you
do things like design a database for the business. I taught myself up to
this point and so many times I know what to do, but I don't know why I'm
doing it. Makes a big difference so thanks again for the help and the
explaination.

Shane
 
Back
Top