Lock Record

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?
 
K

Ken Snell [MVP]

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
 
A

AlCamp

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
 
P

Pat Dools

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.
 

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

Top