Dear All,

i have 4 tables:

- article
- articlenr, descr

- receipt
- receiptnr
- articlenr (fk from table article)
- amount

- consumed
- consumednr
- articlenr (fk from table article)
- amount

- stock
- articlenr (fk from table article)
- amount

Here you can see the definitions of those tables:

CREATE TABLE [dbo].[article](

[oarticlenr] [int] NOT NULL,

[odescr] [varchar](500) COLLATE Latin1_General_CI_AS NULL,

[odate] [datetime] NULL CONSTRAINT [DF_article_odate] DEFAULT (getdate()))

---====================
CREATE TABLE [dbo].[receipt](

[oreceiptnr] [int] NULL,

[oarticlenr] [int] NULL,

[oamount] [nchar](10) COLLATE Latin1_General_CI_AS NULL
) ON [PRIMARY]
GO

--========================
CREATE TABLE [dbo].[consumed](

[oconsumednr] [int] NULL,

[oarticlenr] [int] NULL,

[oamount] [int] NULL
) ON [PRIMARY]
GO

--============================

CREATE TABLE [dbo].[stock](

[oarticlenr] [int] NULL,

[oamount] [int] NULL
) ON [PRIMARY]
GO

This has to be happen:
ofter inserting a new record into the table 'receipt', table 'stock'(this table has always all article numbers) most be update too:

stock.oamount = sum receipt.oamount - sum consumed.oamuont

I hope you guys can help me.

Thanks.