writing changes to tables without record-display

Hi there, Could you please help me, how to write field changes into a table which is not displayed on any form, just a simple table… I tried this code, but something is missing and the SalesHeader table’s self-made field doesn’t get the changes What is missing from the line //xxxxx? I’ve already checked the Globals, the Sales Header table, the new field which I made in it… I’m sure I am missing a specific command to write the changes to the table, but WHAT IS THAT COMMAND? IF CONFIRM('Nem visszafordítható folyamat! Valóban lezárja?') THEN BEGIN CurrOrder:="Order No."; SalesHeader.INIT; SalesHeader.SETFILTER("No.",CurrOrder); IF SalesHeader.FIND('-') THEN BEGIN SalesHeader."Process Slip Status":=SalesHeader."Process Slip Status"::Lezárt; //xxxxx END; Rec.Status:=Rec.Status::Lezárt; CurrForm.UPDATE; END Thanks for your help, MSN:Chinokko@freemail.hu

Citazione:

Hi there, Could you please help me, how to write field changes into a table which is not displayed on any form, just a simple table… I tried this code, but something is missing and the SalesHeader table’s self-made field doesn’t get the changes What is missing from the line //xxxxx? I’ve already checked the Globals, the Sales Header table, the new field which I made in it… I’m sure I am missing a specific command to write the changes to the table, but WHAT IS THAT COMMAND? IF CONFIRM('Nem visszafordítható folyamat! Valóban lezárja?') THEN BEGIN CurrOrder:="Order No."; SalesHeader.INIT; SalesHeader.SETFILTER("No.",CurrOrder); IF SalesHeader.FIND('-') THEN BEGIN SalesHeader."Process Slip Status":=SalesHeader."Process Slip Status"::Lezárt; //xxxxx END; Rec.Status:=Rec.Status::Lezárt; CurrForm.UPDATE; END Thanks for your help, MSN:Chinokko@freemail.hu
Originariamente inviato da Chino22 - 2004 Oct 15 : 11:24:08

I think I’m also missing something. Where did you put that code? Anna

It could be SalesHeader.MODIFY;

or SalesHeader.insert;

quote:

or SalesHeader.insert;
Originally posted by pelle - 2004 Oct 15 : 14:30:03

Indeed :slight_smile: So if you want to insert new Sales Header record, you have to use: SalesHeader.INIT; ... SalesHeader.INSERT And if you want just to modify current active record, you use: ... SalesHeader.MODIFY;

quote:

IF CONFIRM('Nem visszafordítható folyamat! Valóban lezárja?') THEN BEGIN CurrOrder:="Order No."; SalesHeader.INIT; SalesHeader.SETFILTER("No.",CurrOrder); IF SalesHeader.FIND('-') THEN BEGIN SalesHeader."Process Slip Status":=SalesHeader."Process Slip Status"::Lezárt; //xxxxx END; Rec.Status:=Rec.Status::Lezárt; CurrForm.UPDATE; END
Originally posted by Chino22 - 2004 Oct 15 : 11:24:08

A lot of things worry me in this particular piece of code:

    1. If you are trying to modify an existing record, you don’t need the SalesHeader.INIT;
    1. The Sales Header table primary key is “Document Type,No.”. In order to find a specific Sales Order, one should look within the “Document Type”::Order. In your case, by only setting a filter on the “No.” field, you risk finding an Invoice or Credit Memo, etc. with the same No. as the Order you were looking for;
    1. //xxx should probably be SalesHeader.MODIFY, as mentioned before;
    1. The code is most likely being called from a Form based on a custom “Process Slip (? just a guess…)” table. The code should be moved from the Form to the Table, unless some special condition prevents this.