Locking values after entry

  • Thread starter Thread starter JennKriv
  • Start date Start date
J

JennKriv

I assume this question has been asked before but I can't seem to find it so I
thought I would ask again.
I want to be able to lock the values on a form after they have been entered.
I assume that this action would require a save button on the form so that
changes can't be made after but I am not sure what the code would be or where
to actually put it.
 
If you mean at the record level, you can use the Form Current event to
control wheter any editing can be done. This code will restrict editing to
new record only:

Me.AllowEdits = Me.NewRecord
 
Be aware that once you get off of the record, even if all of the
fields have not been filled out, you will NOT be able to change any of
the fields (even to make corrections).

The other way is to be field by field and do code in the oncurrent
event of the form

me.field1.locked = not isnull(me.field1)

But this also means NO changes once you have gotten off of the field.

You may want to think about either calling the form two different ways
(readonly or not readonly) or having some way of turning the allow
edits on or off dependent on requirements.

Ron
 
I agree, Ron, but if you read the OP's request. I gave him exactly what he
asked for.
His next question will be how he can go back and fix errors <g>

And please don't use field when naming controls
me.field1.locked

Forms do not have fields. They have controls. Only tables and queries have
fields.
I don't care what the sloppy documentation from Microsoft says, they are not
fields.
 
Good point Dave. I will try to be more specific with examples next
time. I understand the difference but non-specific examples can lead
to misconceptions.

Have a great day.

Ron
 
Back
Top