Lock Record

  • Thread starter Thread starter Melissa
  • Start date Start date
M

Melissa

I have a database with records that include a date in the
future. Is there way to "lock" the record once that date
occurs so that users can no longer update fields?
 
You could use the Current event to test if that field has a value, and if it
does, lock the controls for that record:

Private Sub Form_Current()
Dim blnLock As Boolean
blnLock = (Len(Me.DateFieldName.Value & "") <> 0)
Me.ControlName1.Locked = blnLock
Me.ControlName2.Locked = blnLock
Me.ControlName3.Locked = blnLock
' etc.
End Sub
 
Melissa,
Use the OnCurrent event for the form to check the entered date (ex.
DateOnForm) vs. today's date. If the entered date is equal to, or greater
than today's date, Lock the record from editing.
If the entered date is less than today's date, allow editing.

Private Sub Form_Current()
If DateOnForm >= Date Then
Me.AllowEdits = False
Else
Me.AllowEdits = True
End If
End Sub

hth
Al Camp
 
Hi Ken,

I would like to lock records, but am using the 'On Current:' Form property
already to auto-populate some header fields when the Form is opened. Can I
just throw this code in the 'AfterUpdate' property of a field that gets set
to a value (of 1, let's say) once a 'Finish' type of button is clicked?
Thanks.
 
Back
Top