preventing field change

  • Thread starter Thread starter Wonixen
  • Start date Start date
W

Wonixen

I've already ask the question, but not the proper way as
answer were not what I expected so here it is again:

I want a way to prevent change to a field once it has been
set.
Some kind of trigger that would work that way when the
field is being updated:

OnUpdate(newValue)
if field value null
accept new value
else
reject value

Is it possible to do something like that ?

I want something embedded in the database (like an sql
trigger) so that programming error will not corrupt the DB.

I do not want to rely on UI to prevent change to a column
 
You say that you don't want the user interface to do this. In that case, I take it that
you are wanting to do this in the table itself. I don't know of any way to get an Access
table to do this.
 
That's exactly what the Locked property of a control
does... it allows an entry "ONCE". After that, it cannot
be changed.

Another way to do it is to set the Enabled property to 0
when the form refreshes and the field has something in
it... like This:

In the OnCurrent property of the FORM:

If Not IsNull(Me![FieldName]) Then Me![FieldName].Enabled
= 0
If IsNull(Me![FieldName]) Then Me![FieldName].Enabled
= -1

The second line reEnables the control when there is
nothing in it. Otherwise, one disabled, it will always be
disabled.

If you don't like the way it goes Gray, then enable and
disable the Locked property as well. When Enabled is set
to NO/0, then Locked would be set to YES/-1 at the same
time. Play around with it. Copy and past the above code
into the OnCurrent propery of the FORM.
 
I've already ask the question, but not the proper way as
answer were not what I expected so here it is again:

I want a way to prevent change to a field once it has been
set.
Some kind of trigger that would work that way when the
field is being updated:

Access does not support Triggers.
I do not want to rely on UI to prevent change to a column

Then you'll have to implement your application in SQL/Server or
Oracle; Access does not provide this capability *except* by using the
user interface. It's easy on a Form, but if you insist that you don't
want to use a form then you're out of luck.
 
Back
Top