Locking specific fields after Inserts

  • Thread starter Thread starter Jasmine
  • Start date Start date
J

Jasmine

Hi ,

I'm looking for a way to lock specific fields in my form
after inserting a record
I do not want to lock the entire sub-form, but only certain field
example : Only Entrydate, Notes

I do however want to be able to write to these fields Prior to insert
but lock the field right after.

The Reason is :
Some users are changing previously entered information thereby
circumventing the system.
If users need to update a previously entered Information I want
them to create a new record with information of that change-
It's almost like a protective Audit Tracking Mechanism.

Any thoughts would be highly appreciated.
 
You could use the current event of the form to lock specific controls. The
specific code depends on whether or not you want to lock controls that have
data in them or you want to lock/unlock the controls depending on whether the
associated record is a new record.

Private Sub Form_Current()
'Choose one of the options
'Lock the control if this is not a new record
If Me.New_Record = False Then
Me.txtLinkTo.Locked = True
Else
Me.txtLinkTo.Locked = False
End If

'==================================================
'OR option two
'lock the control if the control's value is not null
Me.txtLinkTo.Locked = IsNull(Me.txtLinkTo)
'==================================================

End Sub

John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
 
Back
Top