Don't allow to update a field, if not null

  • Thread starter Thread starter Luis Marques
  • Start date Start date
L

Luis Marques

I have a field on a form.

I need a code, that performs this operation:
-If the field is null, i can update it. If not, the access just allows
changes on the field with a password.

Anyone can help me
 
In the Current Event Lock or Unlock the control
Assuming a control named txtLinkTo on your form.

Private Sub Form_Current()
Me.txtLinkTo.Locked = Not (IsNull(TxtLinkTo))
End Sub

You can then use similar code in an unlock button if you want to allow some
one to unlock the control and change the input.
Me.txtLinkTo.Locked = False

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 
Hmm...that weird...I assumed you tested in on a cell that already have input
too?

If "On Enter" doesn't work, you could always pass the contents of the field
into a global variable with a "Before Update" event and pass the new contents
into another global variable with a "After Update" event, and run the
verification in the "After Update" event.

Of course, what Mr. Spencer did looks much shorter and neater! ^_^

YMMV.
 
Back
Top