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

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
 
D

DCPan

Did you have a IF statement inside the event?

If ME.FieldName is null THEN
ELSE
End IF
 
J

John Spencer

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

DCPan

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.
 

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