vba - Run SQL on field value change using previous value and new value -
i'm new vba , access , have inherited database needs improvement.
i have form in access shows table editing:
when labour rate value in table changed need run following query update table:
update finishedproduct set labourrate = newvalue labourrate = oldvalue;
(yes design of database bad.)
which event can handle react labour rate changing?
how can previous value of field , new value of field?
something don't know: when user changes labour rate value in grid table updated immediately?
you can use beforeupdate event of form , oldvalue
has previous value (value
new value):
private sub form_beforeupdate(cancel integer) msgbox me.txtlabourrate.oldvalue msgbox me.txtlabourrate.value end sub
this happens just before record updated. cannot use afterupdate
event of form because oldvalue
same new value.
beforeupdate happens immediately before record updated. record updated - unless cancel
argument set true
. there current
event form happens after record has been updated , old/value reflect of current row - row have moved to.
it possible use afterupdate
event of form, there no need: use beforeupdate
. in order use afterupdate
need use current
event store old/current value in variable.
when field changed record not updated immediately, whole record updated when move away current row (record).
Comments
Post a Comment