Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

Copy records from one table into another

(0) ShareShare
ReportReport
Posted on by

HI! I have 4 tables: tab1header, tab1lines and tab2header, tab2lines. I want to create something like posting -  copy information from one table (tab1heder and lines) to tab2heder and lines, then delete order from 1table. I am not good at using filters and its issue difficult to me. How I can do it? Can I find similar code in standard solution?

*This post is locked for comments

  • Sathish C Profile Picture
    184 on at
    RE: Copy records from one table into another

    Hi bharath karunakaran,

    can you find out any error in the code. suggest me some alternate code for the same function

  • bharathkarunakaran Profile Picture
    475 on at
    RE: Copy records from one table into another

    Your are trying copy some records from one table to another right.

    By the way do you have something like header and lines part in it.

    Try to debug it and can use MESSAGE function to check where the error is coming out.

    thanks

    Warm regards

    bharathk

  • Sathish C Profile Picture
    184 on at
    RE: Copy records from one table into another

    qwsas.PNG

    This code is not working for me in line part 

  • bharathkarunakaran Profile Picture
    475 on at
    RE: Copy records from one table into another

    Sure it will work .Try the above thing.

    Thanks

  • bharathkarunakaran Profile Picture
    475 on at
    RE: Copy records from one table into another

    Hi Serege,

    You can also try to create a two forms in which form1 as header and lines as a subform and then insert a action command from toolbox.

    In the second form do the same process above except the action button.

    Note: You must link the form and subform and also you must write some code in the action command for the transfer function .

  • Suggested answer
    Tina Menezes Profile Picture
    2,582 on at
    RE: Copy records from one table into another

    Hi,

    You need to use Insert function and copy values from table 1 header and lines to table 2 header and lines something like below:

    Table2Header.INIT;

    Table2Header.VALIDATE(Table2Header.Field1,Table1Header.Field1);

    ...//Do this for all fields

    Table2Header.INSERT;

    Table2Lines.INIT;

    Table2Lines.VALIDATE(Table2Lines.Field1,Table1Lines.Field1);

    ......//Do this for all fields

    Table2Lines.INSERT;

    //Now delete this record from first table

    Now do setrange to find this record in table 1 and use delete function

    Table1Header.DELETE;

    Table1Lines.DELETE;

    You can check following links for reference:

    https://msdn.microsoft.com/en-us/library/dd355219.aspx

    https://msdn.microsoft.com/en-us/library/dd355378.aspx

    https://dynamicsuser.net/nav/f/beginners/12538/how-to-add-new-record-in-a-simple-table

  • Suggested answer
    Amol Salvi Profile Picture
    18,696 on at
    RE: Copy records from one table into another

    Is transaction table and posting table fields are same . If yes then use TransferFields. Or write code for import data from one table to another.

  • Suggested answer
    Zaid Tariq Profile Picture
    2,274 on at
    RE: Copy records from one table into another

    Hi, Can you let me know that which Tab1header field has relationship with the field in Tab1lines table?

  • Suggested answer
    RockwithNav Profile Picture
    6,663 on at
    RE: Copy records from one table into another

    Why dont you try something by yourself and take some help from standard NAV code and then come back to us with your code.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Microsoft Dynamics NAV (Archived)

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans