How to update just modified fields

dndn Member Posts: 71
I am stuck with a problem. I have a table(tmpItem) who is a copy of Item-table.
TmpItem use for Itemimport before I put them into Item-table.

Now I want to update records in Item table with tmpItem-records there data had been changed in tmpItem-record.

I don't what to use Transferfields...because there is risk I overwrite data in Item. IS there any good trick for my little problem?
:-k

Comments

  • jonsan21jonsan21 Member Posts: 118
    1. Create a Report, with TmpItem as DataItem
    2. Declare Item as record in Global Var
    3. At the DataItem's OnAfterGetRecord trigger, do this:
    IF Item.GET("No.") THEN BEGIN
      Item.Description := TmpItem.Description
      Item.MODIFY;
    END;
    
    (this will change just the Description of Item, you can do so with the any other fields in Item table)

    Rgds,

    Jon.
    Rgds,

    Jon.
  • dndn Member Posts: 71
    jonsan21 wrote:
    1. Create a Report, with TmpItem as DataItem
    2. Declare Item as record in Global Var
    3. At the DataItem's OnAfterGetRecord trigger, do this:
    IF Item.GET("No.") THEN BEGIN
      Item.Description := TmpItem.Description
      Item.MODIFY;
    END;
    
    (this will change just the Description of Item, you can do so with the any other fields in Item table)

    Rgds,

    Jon.

    Well..if it only description-field I can use modify. But in this case there are several fields. I use dataport to import data into tmpItem then I have a form that I can correct data I imported and then update fields in Item-table..is I clear?
  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    dn wrote:
    [...] then I have a form that I can correct data I imported and then update fields in Item-table..is I clear?
    Then you only need to use the fields which are on your form (and which users can edit):
    IF Item.GET("No.") THEN BEGIN 
      Item.Field1 := TmpItem.Field1;
      Item.Field2 := TmpItem.Field2;
    
      ...
    
      Item.MODIFY; 
    END;
    
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
Sign In or Register to comment.