Create own ValidateTable relation

tompynationtompynation Member Posts: 398
Hi, i created form with a textbox which contains following code:

<Control1000000002> - OnValidate()
IF gv_Kleur <> '' THEN BEGIN
lv_Item.RESET;
lv_Item.SETRANGE("Custom No.",gv_Kleur);
IF NOT lv_Item.FINDFIRST THEN
MESSAGE(Text006,gv_Kleur);
END;

<Control1000000002> - OnAfterValidate()

<Control1000000002> - OnLookup(VAR Text : Text[1024];) : Boolean
lv_Item.RESET;
lv_Item.SETRANGE("Item Category Code",'COLOR');
IF FORM.RUNMODAL(31,lv_Item) = ACTION::LookupOK THEN BEGIN
gv_Kleur := lv_Item."Custom No.";
gv_KleurNo := lv_Item."No.";
END;

Now when a user enters an unexisting Custom No. he gets the error message saying that there is no Item with that Custom No.

But he can still leave the textbox and let the unexisting number stand there...

I want to same functionallity like when you enter an unexisting Item No. inside a Sales Order.
So the user shouldnt be able to move out of the field untill he has corrected the incorrect number...

How to do that?

Answers

  • krzychub83krzychub83 Member Posts: 120
    use ERROR () instead MESSAGE ()
    Have a nice day
  • tompynationtompynation Member Posts: 398
    hehe, that was easy...

    I thaught that when using the Error function it would close the form also

    Anyway, works fine thanks
Sign In or Register to comment.