Topic: procedure that is not triggered from a form
I have 2 sections of script that do the same thing in filling out a form. I want to make it a separate procedure and call if from the places where that code needs to run.
I am not sure how to do this - the 2 places that it runs now need place an id value in a drop down filed and text in a text text field, then they need to end and call this other "procedure" that takes the id form the drop down and does several sql selectes and completes other fields in the form.
I tried putting the code in a procedure called formfill
procedure Formfill (Sender: string);
var
Ccapacity, Ctare, Cdotdate, Ccustomern, trfcontid, ContID: string;
dt: TDateTime;
rt,lastcust,ContSTR,Len: integer;
begin
ContID := IntToStr(subcontainerfind.TableGrid1.dbItemID);
Ccapacity := SQLExecute('SELECT ContainerCapacity FROM Containers WHERE id=' + ContID );
Ctare := SQLExecute('SELECT ContainerEmpty FROM Containers WHERE id=' + ContID );
Cdotdate := SQLExecute('SELECT DOTInspDate FROM Containers WHERE id=' + ContID );
lastcust := SQLExecute('SELECT id_Customers, id_Containers, max(id) from FillRecords where id_Containers =' + ContID + ' AND returned = 0 group by id_Customers limit 1');
Ccustomern := SQLExecute('select CustomerWholeName FROM Customers WHERE id=' + IntToStr(lastcust) );
end
and then calling it from the end of the original procedure like this
Formfill();
this isn't working or I am doing it wrong.