MS ACCESS: LOCK FIELD ON_EXIT

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How can I lock a field on exit? I do not want to lock the whole form. The
form has almost 20 fields. Once the user fills all the fields or most of the
fields and closes the form, I want one specific field (year) to be locked so
that when the user reopens the forms he cannot change that specific field but
should be able to edit any of the other fields. The field name is year
 
Paul Joseph said:
How can I lock a field on exit? I do not want to lock the whole form. The
form has almost 20 fields. Once the user fills all the fields or most of the
fields and closes the form, I want one specific field (year) to be locked so
that when the user reopens the forms he cannot change that specific field but
should be able to edit any of the other fields. The field name is year

In the Current event of the form...

Me![Year].Locked = Not IsNull(Me![Year])

This assumes that the control bound to the field [Year] is also named "Year".

Bad name for a field by the way. There is a function named Year and thus it is
a reserved word in Access and you could see problems where you are referring to
the field and Access thinks you want the function.
 
Paul,

Put code like this on the Current event of the form...
Me![Year].Locked = Not IsNull(Me![Year])

By the way, as an aside, the word Year is a Reserved Word (i.e. has a
special meaning) in Access, and it is best not to use it as the name of
a field or control or database object.
 
Hey, great minds think alike :-)

Steve Schapel said:
Paul,

Put code like this on the Current event of the form...
Me![Year].Locked = Not IsNull(Me![Year])

By the way, as an aside, the word Year is a Reserved Word (i.e. has a special
meaning) in Access, and it is best not to use it as the name of a field or
control or database object.

--
Steve Schapel, Microsoft Access MVP


Paul said:
How can I lock a field on exit? I do not want to lock the whole form. The
form has almost 20 fields. Once the user fills all the fields or most of the
fields and closes the form, I want one specific field (year) to be locked so
that when the user reopens the forms he cannot change that specific field but
should be able to edit any of the other fields. The field name is year
 
Back
Top