Doubt in SETFILTER

kishi_gkishi_g Member Posts: 162
Hi,
I created one table and form. table fields are NUMBER and FROMCODE.Primary key is NUMBER.
I gave data on this table like this.

NUMBER FROMCODE
1 100
2 101
3 102
4 200
5 201
6 202
7 300
8 301
9 302

In form I wrote the code in ONOPENFORM Trigger:

code1 := '100' + '..' + '102';
code2 := '200' + '..' + '202';
SETFILTER(fromcode,code1,code2);
SETFILTER(fromcode,'%1|%2',code1,code2); //I tried this code also.

when i run this form no records was showed.I want to show 100 to 202 only by using code1 and code2.

how can i do that?????



Thanks & Regards,
Kishore.

Comments

  • McClaneMcClane Member Posts: 40
    If you want to open the form with the filtered record every time you open it, i would use the SourceTableView Property of the form and set the filter there.

    if not, try SetRange(code,from,to) in the onOpenFormTrigger or, what i think is best, open the form by using a filtered record as a Variable and form.runmodal(NumberOfForm,FilteredRecord).
  • kishi_gkishi_g Member Posts: 162
    Hi McClane,
    Thanks for ur reply. is it possible to show the combination of these two(code1 and code2) by using this code. becaz i will use this code in another form.

    code1 := '100' + '..' + '102';
    code2 := '200' + '..' + '202';
    SETFILTER(fromcode,code1,code2);


    regards,
    kishore.
  • WiechardtWiechardt Member Posts: 25
    Hi Kishore

    The best way to test if your filter is going to work is to run your table and apply the filter manually before trying to construct a filter and wondering whether it is actually going to work.

    For example, you want 2 ranges to show:
    Range 1: 100..102
    Range 2: 200..202

    In NAV it's not possible to apply a filter with: FromRange..ToRange, in other words, 100..102..200..202, instead you should build a filter that includes an OR constructor between the 2 ranges, something like 100..102|200..202.

    One way to achieve this is by constructing and applying the following filter: SETFILTER(fromcode, FilterString) WHERE FilterString is set to '100..102|200..202'

    Hope this helps! :lol:
  • kishi_gkishi_g Member Posts: 162
    Hi Wiechardt,
    Thanks for ur reply. I take Range3 as code.

    Range 1: 100..102
    Range 2: 200..202

    Range3 := 'Range1|Range2';
    setfilter(fromcode,Range3);

    when i run the form no records was showing.


    Thanks & Regards,
    Kishore.
  • BeliasBelias Member Posts: 2,998
    you wrote
    Range3 := 'Range1|Range2';
    

    but maybe this is better.... :mrgreen::mrgreen:
    Range3 := Range1 + '|' + Range2;
    

    with your method, nav will apply this filter: 'Range1|Range2',
    not the values of the txtconst!! [-X
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • i4tosti4tost Member Posts: 208
    please write the filter that you see after you run form. It should be displayed when you press TableFilter
  • kishi_gkishi_g Member Posts: 162
    Hi Guys,
    Thanks for ur replies. I got the solution by using FORMAT function.


    Range3 := FORMAT(Range1) + '|' + FORMAT(Range2);

    setfilter(fromcode,Range3);



    Thanks & Regards,
    Kishore.
Sign In or Register to comment.