Lock individual records instead of all records on form

  • Thread starter Thread starter Michael Walsh
  • Start date Start date
M

Michael Walsh

I'd like to lock records in a form and have used this...

If Me.Lock = True Then
Me.AllowEdits = False
Else
End If

But the problem is this, not matter whether this is the
OnLoad event or OnOpen event it only works with record 1.
If record 1 is locked all of the records are locked, if
record 1 is unlocked, all of the records are unlocked
whether or not the lock checkbox has been checked in each
individual record.

How can I have the code evaluated each time a record is
located instead on the one time when the form is opened or
loaded?

I'm thinking that I coould put this code in the On Got
Focus of each control on the form, but that seems like a
lot of work. So, I'm hoping there's something easier.
 
Michael Walsh said:
I'd like to lock records in a form and have used this...

If Me.Lock = True Then
Me.AllowEdits = False
Else
End If

But the problem is this, not matter whether this is the
OnLoad event or OnOpen event it only works with record 1.

Because OnOpen and OnLoad only fire once each when the form is opened. If
you want the code to run for each record visited then you need to use
OnCurrent.
 
I tried OnCurrent and that wasn't working either until I
realized I needed to add the else statement Me.AllowEdits
= True
 
Back
Top