Setrange Prob.

upasanisandip
Member Posts: 405
Hi ,
Can anyone know how to solve this problem.
I want the min. serial no. value in table.
so using following code but getting 10 as return value.
Actual serial no. value in table is 20.
Vehicle is a record variable of subtype Vechicle Table.
Vehicle.SETRANGE(Vehicle."Serial No.",10,300);
MESSAGE('%1',Vehicle.GETRANGEMIN("Serial No."));
Thanks in adv.
Sandip.
Can anyone know how to solve this problem.
I want the min. serial no. value in table.
so using following code but getting 10 as return value.
Actual serial no. value in table is 20.
Vehicle is a record variable of subtype Vechicle Table.
Vehicle.SETRANGE(Vehicle."Serial No.",10,300);
MESSAGE('%1',Vehicle.GETRANGEMIN("Serial No."));
Thanks in adv.
Sandip.
0
Comments
-
GETRANGEMIN gets you the minimum value of the filter you created, not the minimum value in the DB.
To get the min value, you need to create a loop to check it.Vehicle.SETRANGE("Serial No.",10,300); IF Vehicle.FIND('-') THEN BEGIN MinSerialNo := Vehicle."Serial No."; REPEAT IF MinSerialNo > Vehicle."Serial No." THEN MinSerialNo := Vehicle."Serial No."; UNTIL Vehicle.NEXT = 0; END;
MESSAGE('%1',MinSerialNo);Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
Hi
Dear friend it will always give 10.
Better take on key which is sorting on Serial NO.
Do Setcurrent key
then setrange
and then find(-);
u will get the result
Soln given by kriki will also workThanks & Regards,
Aniruddha0 -
aniruddha_majumdar wrote:Hi
Dear friend it will always give 10.
Better take on key which is sorting on Serial NO.
Do Setcurrent key
then setrange
and then find(-);
u will get the result
Soln given by kriki will also work
The extra-key solution of aniruddha_majumdar is faster for reading, because with 1 read it has the correct record, but it will be slower to write in the table.
So if the code to read it has NOT to be lightening-fast for some reasons, it is best to use my solution.
If your code has to be lightening-fast (e.g. it is part of a posting-procedure), then it is best to use the extra-key-solution.Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
ok thanks . I exactly want the same.0
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