How to Automatically Insert Record in RUN Form

bob_upbob_up Member Posts: 155
I have written a 'batch control' form for purchase invoices. The user can add, change or delete purchase invoices from this form, then post them as a batch once the total amounts add up to a batch control total.

I have added a function to form 51 'Purchase Invoice' , by which I pass the batch ID and the purchase header from the batch header form (if the user has selected to modify an existing invoice in the batch).

If the user clicks the 'Insert' option on the batch header, I would like to open form 51 in insert mode, ie as if the user had pressed F3 in that form.

Is this possible ?

Comments

  • kinekine Member Posts: 12,562
    May be you need to pass empty record to the form when running it? (or you can use SendKeys to send {F3}).
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • garakgarak Member Posts: 3,263
    is your batch form based on table 38 or is it an Form without an source table :?: If yes (based on table) and u will make it possible to add record only in form 51 you can do following.

    set propertie "insert allowed" to false.
    Make an menu button with Shortcut F3. Behind this, you set your source to insert an new Header.
    PurchHeader.init;
    PurchHeader."Document Type" := PurchHeader."Document Type"::Invoice:
    PurchHeader."No." := '';
    PurchHeader.insert(true); //new No. from No Series
    Form.runmodal(51,PurchHeader);
    

    Noew, if user press F3 on "batch form" the form 51 will beopend with an new No.

    Regards
    Do you make it right, it works too!
  • RuleRule Member Posts: 34
    What you can do is

    On the open form trigger put this code

    rec.INIT;
    rec.MARK(TRUE);
    rec.MARKEDONLY(TRUE);


    Now you open on an empty record.
    The problem is that it will be the only record visible in the Form.

    Hope you can use this
    Realisations are only limited by the borders of imagination
Sign In or Register to comment.