Need help on Table Post Code - Function ValidateCity
jemmy
Member Posts: 247
Folks,
Anyone knows why we need to add
IF PostCodeRec2.NEXT = 1 THEN
in the following code
Thanks in advance as always,
Jemmy
Anyone knows why we need to add
IF PostCodeRec2.NEXT = 1 THEN
in the following code
ValidateCity(VAR City : Text[30];VAR PostCode : Code[20])
IF NOT GUIALLOWED THEN
EXIT;
IF City <> '' THEN BEGIN
SearchCity := City;
PostCodeRec.SETCURRENTKEY("Search City");
PostCodeRec.SETFILTER("Search City",SearchCity);
IF NOT PostCodeRec.FIND('-') THEN
EXIT;
PostCodeRec2.COPY(PostCodeRec);
IF PostCodeRec2.NEXT = 1 THEN
IF FORM.RUNMODAL(FORM::"Post Codes",PostCodeRec,PostCodeRec.Code) <>
ACTION::LookupOK THEN
EXIT;
PostCode := PostCodeRec.Code;
City := PostCodeRec.City;
END;
Thanks in advance as always,
Jemmy
0
Comments
-
Hi Jemmy
This code checks if there is more than 1 city in the post code table and if so displays the list of cities with the criteria you have entered.
Regards
Albert0 -
I removed the line contained with
PostCodeCheck.AddressValIsPostCodeCity;
now it works, but I'm still curious... :?
Alberth, how about if the city is the last record in the list (means that NEXT = 0)?0 -
Hi Jemmey
That is correct0 -
If there are no records or a single record matching the filter criteria then the function exits immediately. If there are multiple records matching the criteria then the user is asked to select the desired one from a list. The obvious way to code this would be to use the COUNT function and test for COUNT > 1. But this is extremely slow on large tables because it must return the exact count and all we are really interested in is if there is more than one record. Thus, NEXT = 1 tells us that another record is found.0
-
Hi JReynolds!
Then the last record in the list won't open the form modal.
You have pointed it well. A good trick from the programmer.
Thanks a lot JReynolds! =D>
Jemmy0
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
- 322 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