Re: Lock Record

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Ken Snell [MVP] (kthsneisllis9_at_ncoomcastt.renaetl)
Date: 10/07/04


Date: Thu, 7 Oct 2004 18:37:45 -0400

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

-- 
        Ken Snell
<MS ACCESS MVP>
"Melissa" <anonymous@discussions.microsoft.com> wrote in message
news:104401c4acbd$72152000$a301280a@phx.gbl...
> 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?


Relevant Pages

  • Re: lock all fields
    ... Tried the code Ken and it compiled but didn't lock the fields for some ... Private Sub Form_Load ... potentially want to cancel the open event based on some parameter other than ... a value in a form's controls or fields. ...
    (microsoft.public.access.forms)
  • Re: Lock specific record fields
    ... Do you want to lock when Status=true? ... Private Sub Form_Current ... The other way is to toggle the Locked property of individual controls based ... For Each ctl In Me.Controls ...
    (microsoft.public.access.formscoding)
  • Re: LOCK A RECORD
    ... If, for example, you have a "CompleteDate" field, and want to disallow edits ... loop through the controls and set their Locked property. ... - The code calls itself recursively to lock any subforms as well. ... Dim blnLock As Boolean ...
    (microsoft.public.access.forms)
  • Re: Suggested approaches/best practices
    ... check the value of the form's NewRecord property: ... Private Sub Form_Current ... ' New record: don't lock ... How do I re-lock the controls when the user moves to a new record? ...
    (microsoft.public.access.formscoding)
  • Re: Prevent edits - unexpected effects
    ... Private Sub Complete_AfterUpdate ... If the check box is true, this will lock it. ... Therefore the subform control is locked well. ... Even unbound controls ...
    (microsoft.public.access.forms)