Hello
I have a new entry on the form, open it and save it to the database with a script, and the next time you go to view or change the entry, then when you try to click on this script, a repeated entry is added. How to avoid it?
Here is the button script:
procedure frmOrderProduct_Button6_OnClick(Sender: TObject; var Cancel: boolean);
var
s:string
maxID:string;
maxID2:string;
maxID3:string;
maxID4:string;
begin
// Pass from product combobox to another combobox
begin
//Save the value in the additional table with the button
maxID := SQLExecute('SELECT MAX(id) FROM ORDERT');
maxID2 := SQLExecute('SELECT id_employees FROM ORDERT WHERE id= '+maxID+'');
maxID4 := SQLExecute('SELECT MAX(id) FROM Product');
SQLExecute('INSERT INTO orderproduct (Quantity, QuantityFact, Cost, summa, kolminus, ID_ORDERT, id_employees,id_product) VALUES('+frmOrderProduct.edQuantity.Text+','+frmOrderProduct.Edit1.Text+','+frmOrderProduct.edCost.Text+ ','+frmOrderProduct.edTotal.Text+','+frmOrderProduct.kolminus.Text+','+maxID+','+maxID2+','+frmOrderProduct.cbProduct.sqlValue+')');
UpdateDatabase('orderproduct');
frmOrderProduct.Button6.dbDontResetID := False;
end;
begin
frmOrder.bSearchGridOrdered.Click;
end;
end;