public update function

I have an update function in the OnClick event of a control called Torderid.I want to make
a global funnction to be executed from every form which has a control TOrderid.In
other words i want to use this update function in many forms which have a control
called TOrderID.

The following code is executed in the OnClick event of the control TOrderID :

Dear Sir,
Thank you so much for your advice.It works excellent and saves a lot of time!!!!
No that i solved the problem, may i ask you an additionalk question,applying your solution. .I think i can further simplyfy my coding.I have two functions,they are similar ,only the Where clause is dufferent.In the first function, like the above , the diferring part of the where clause is
WHERE orders.orderid
in the other function the differing part of the where clause is :
WHERE orders.paymentid

So you see, the two functions are different only in that part of the where clause.Is it possbile to create a constant and then replace this constant,or something like that?
I am very grateful to you anyway

Re: public update function

Dear Charlotte,

I want to thank you to you and all other contributors to this forum for the excellent advice
and wonderful solutions i have received.
The update code suggested by you works wonderful and without errors. I had 4 functions before and

now i will have one!!!
May i ask you for some additional help? I have simplified my code because i wanted to be more

clear and also i thought i could manage it myself.But i cant.
Actually after the update process,which you have solved sucessfully, i have to carry our a

Re: public update function

OK, this one is a little different because you're trying to delete from different tables. That means you have to pass both the WHERE string and the table name into the function. You could do it like this: