New Records and Mandatory Fields

kimwkimw Member Posts: 6
Hello

my problem is when i try to create a mandatory field in a form on the OnNewRecord Button like

IF Name = '' THEN BEGIN
MESSAGE('Bitte das Feld Name ausfüllen');
CurrForm.Name.ACTIVATE();
END;

and i push the new Record Button he shows me the Message but he creates the new Record and jump to the new record... in my opinion he should keep the current data record and jump to the empty field.

how can i realise it?

an another try was that i set in the table on the onmodify and oninsert button the Testfield(name)

but then he test the name field of the new created record... and that is normaly empty. :(

you understand my problem?

Comments

  • Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    Have you tried to search the forum for the "mandatory" term?

    Loads of infos about this.

    Basic solution though is not to do it; It is not supported by Navision. You should educate your users instead of porgramming not-navision like code.
  • kimwkimw Member Posts: 6
    i have search and look to all the other treats of mandatory fields.. and everyone tells there to use the testfield(name) on the table...

    but i do something wrong... and i have tried so much...
    has somebody a step by step tutorial maybe? :shock:

    i need a field that must get an value befor the user can close it / before he can create a new record.
  • Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
  • zimiwingszimiwings Member Posts: 20
    Well, use the ERROR statement instead of the MESSAGE. That should do, what you intend.

    Regards
    Daniel Zimmermann
    Daniel Zimmermann
  • kimwkimw Member Posts: 6
    well when i used this code

    IF ("No." <> xRec."No.") AND (xRec."No." <> '') THEN BEGIN
    IF xRec.Name = '' THEN BEGIN
    Rec := xRec;
    xRec.TRANSFERFIELDS(Rec);
    CurrForm.UPDATE(FALSE);
    MESSAGE('Your Message');
    END;
    END;

    on the Form 5050 (contact Card)
    i try it on the oninsert/onmodify/onclose trigger...

    I get no effekt.. navision creates a new record when i push the button new record set. and shows no message when i close the window.
Sign In or Register to comment.