Simple Question - IN Statement

Angelo
Member Posts: 180
Hi master,
Is it possible to use "IN" statement for choose range of value?
for example,
If GLAccount."No." IN ('50000..51000') then ...
I've already tried but cant. Maybe there is something missing in my code. Please advice....
Thanks
Is it possible to use "IN" statement for choose range of value?
for example,
If GLAccount."No." IN ('50000..51000') then ...
I've already tried but cant. Maybe there is something missing in my code. Please advice....
Thanks
0
Comments
-
Nope, ranges don't work with IN statements, but you already knew that0
-
is it possible to use IN if the option value is very big without key in one by one in bracket(hardcode)?
I dont want to use0 -
Here is some trick:
you can use filter on GLAccount like that:
GLAccountRec.SETFILTER("No.",'%1..%2&%3',50000,51000,GLAccountNo);
IF GLAccountRec.FINDFIRST THEN ... ;Sincerely yours, GRIZZLY
Follow my blog at http://x-dynamics.blogspot.com0 -
Use > and <NAV - Norton Anti Virus
ERP Consultant (not just Navision) & Navision challenger0 -
Yes it's possible to use ranges and the IN statement.
if GlAccount."No." IN ["50000".."51000"] then
1 -
Torben R. wrote:Yes it's possible to use ranges and the IN statement.
Tested in a 2009 classic client with strings and integers. Worked fine. I was surprised. I didn't recall this being possible.0 -
if GlAccount."No." IN ["50000".."51000"] then0
-
I notice that the example uses double quotes instead of single quotes. Could that be the problem? I don't know when they syntax became available.0
-
from the Dev I manual...Relational Expressions for Set Inclusion
The relational operator IN is used to determine inclusion. It determines if the first
term is in a specific set. Therefore, it requires a list of values, a set, to compare
the term to. This list is part of the expression and is called a set constant.
Set Constant
There are no variables of type set, but there are constants of type set. A set
constant consists of an open square bracket ([) followed by a list of allowed
values separated by commas, followed by a close square bracket (]). For
example, a set of all the even numbers from one to ten looks like this:
[2,4,6,8,10]
Besides individual values, a member of a set can also be a range of values. A set
of all the numbers from one to twenty not evenly divisible by ten looks like this:
[1..9,11..19]
In addition, an individual value or a value used as part of a range can actually be
an expression. A list of numbers from 10 to 20, but not including the variable n
(as long as n was from 10 to 20), looks like this:
[10..n-1,n+1..20]kind of fell into this...0 -
Ranges are acceptable if the value type is Integer but are not acceptable if the value type is Code like :if GlAccount."No." IN ["50000".."51000"] then
@matttrax
you said that range can be done in classic client 2009 and worked fine. maybe you mean that range can be done if value type is integer,isnt it? :-k0 -
No, the following code compiles and runs just fine in a NAV 2009 SP1 Classic Client.
IF 'A' IN THEN
MESSAGE('Found A')
ELSE
MESSAGE('Did not find A');0 -
matttrax wrote:No, the following code compiles and runs just fine in a NAV 2009 SP1 Classic Client.
IF 'A' IN THEN
MESSAGE('Found A')
ELSE
MESSAGE('Did not find A');
This ran even in 4.0 so it was around for a whileNAV - Norton Anti Virus
ERP Consultant (not just Navision) & Navision challenger0 -
You can use "IF temp IN [1..9] then" in NAV 4.0 SP3
Just check it.Zephyr0 -
You can use "IF temp IN [1..9] then" in NAV 4.0 SP3 also.
Just check it.Zephyr0 -
It's always good to learn something new. Four years of NAV development and I didn't realize this was an option. :oops: So much for those giant CASE statements.0
-
Anybody succeeded in using a variable with a IN statement?
Sort of
IF AnyRecord.Field IN [TextField] THEN ...
where TextField should contain something 'VALUE1,VALUE2,VALUE3'.
Thanks
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