Lock Field from Update After Entry

  • Thread starter Thread starter GREGR
  • Start date Start date
G

GREGR

Hi,

I have a date field on a subform. After entring the date
and moving to another field, then I would like to lock
the field from being changed, without locking the form.

Is this possible? If so, what code would I use??? Would
I use and after update event? Whatever I use I get a
debug can't do this while field has focus...

Thanks in advance,
Greg
 
I'd try using an OnExit or LostFocus event. I'd say you'd probably want
to check to make sure it was filled out before you went and locked it
just in case someone accidentally enters through it. You'd probably
also want to make sure that the text box has a date format so you don't
get crazy or non-dates in there. And if the date entered is always
going to be today's date then I would just suggest keeping it locked and
putting =Date() in the text box's Default Value. If it won't be today's
date, try the following.

Something to the effect of in txtDate OnExit Event (aircode):

if isnull(Me!txtDate) then
msgbox "Please Enter Date", vbOKOnly, "No Date!"
Me!txtDate.SetFocus
else
Me!txtDate.Locked
end if

HTH
Bill
 
Back
Top