Topic: Saving Record

Is it possible to save some records of a table to and other table use script and some records of same table by using button action to get a id key.
For example there are three table A, B, C. I want to save some fields of table A to Table C using script while some records from table C to C using button action property to get same one id? How it will be? Any idea?

2 (edited by brian.zaballa 2022-06-25 16:41:45)

Re: Saving Record

I'm not so sure to what will be the implementation of the idea but here's a sample that will get you started. Hope it'll help.

Post's attachments

Attachment icon save.zip 549.52 kb, 212 downloads since 2022-06-25 

brian

Re: Saving Record

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;

Re: Saving Record

I could use the standard means of saving with a button through the program, but the problem is that the id_employees table with data on customers does not want to write the id itself in the OrderProduct, can there be a way to display the ID on the form?

Re: Saving Record

Please help me, I just need from the form: employees - I select names through the search - then they go as a new record in OrderT - then we create a new record in the OrderProduct form and on this form, when saving with a button without a script, id_employees are NOT saved (this field is located in the table Orderproduct

Table - Employees
Table - OrderT
Table - OrderProduct

6 (edited by brian.zaballa 2022-07-11 20:21:51)

Re: Saving Record

frmOrderProduct.Button6.dbDontResetID := False;

This code will always make make it add new record if you are not closing the form after saving.

it will be much appreciated if you can attach if not your project, just a simple one so that people can check it out easily. It is much easier to debug with it

brian

Re: Saving Record

brian.zaballa wrote:
frmOrderProduct.Button6.dbDontResetID := False;

This code will always make make it add new record if you are not closing the form after saving.

it will be much appreciated if you can attach if not your project, just a simple one so that people can check it out easily. It is much easier to debug with it

Thanks!!!