Locking specific fields after Inserts

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.
 
J

John Spencer

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
 

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