Hello,
I have detail sections in several subforms that are used to fill daily
order data per product. Each row contains textboxes for the weekdays
and a locked textbox (txtTotal) for the week's sum. The week's sum is
also contained in the underlying table and I would like to update it
whenever any of the MonOrder .. SunOrder are changed. I believe the
easiest way to do this is in the backend (SQL Server) using a trigger
(?) - it would save me to go through the many subforms and finding the
event that is triggered when txtTotal.Value changes.
If there is a simple alternative to using a trigger, please tell me.
I think it can be achieved with a simple trigger that updates a row in
one table based on updates of corresponding fields of same row. Its a
"week total" field that sums up values of 7 singular "day" fields. Here
is what I have come up with using the TSQL documentation.
CREATE TRIGGER trigger_stocksum ON tblStock FOR UPDATE
AS
IF UPDATE(MonOrder) OR UPDATE(TueOrder) OR UPDATE(WedOrder) OR
UPDATE(ThursOrder) OR UPDATE(FriOrder) OR UPDATE(SatOrder) OR
UPDATE(SunOrder)
SET TotalOrder =
(MonOrder+TueOrder+WedOrder+ThursOrder+FriOrder+Sa tOrder+SunOrder)
all these fields (including TotalOrder) are contained in tblStock, I
get a syntax error
Server: Msg 170, Level 15, State 1, Procedure trigger_stocksum, Line 4
Line 4: Incorrect syntax near '='.
Can somebody please help me?