Create own ValidateTable relation

tompynation
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?
<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?
0
Answers
-
use ERROR () instead MESSAGE ()
Have a nice day0 -
hehe, that was easy...
I thaught that when using the Error function it would close the form also
Anyway, works fine thanks0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions