Filter using more than one fields at a time

smic1983
smic1983 Member Posts: 27
Hi
Is it possible to filter the data using two fields at a time.
Eg: Where (FieldName1 ="Value1") or (FieldName2 ="Value2")

from the Setfilter and Setrange i can use only one field at a time. Is it any other way is there??????

Regards,
Michael

Comments

  • DenSter
    DenSter Member Posts: 8,307
    Nope you can only set fitlers one field at a time.
  • Denis_Petrov
    Denis_Petrov Member Posts: 107
    Michael

    did you try this:

    MyTable.SETFILTER(Field1, Value1);
    MyTable.SETFILTER(Field2, Value2);

    works great for me...
    Best regards,

    Denis Petrov.
  • ara3n
    ara3n Member Posts: 9,258
    Michael

    did you try this:

    MyTable.SETFILTER(Field1, Value1);
    MyTable.SETFILTER(Field2, Value2);

    works great for me...


    The main request Michael posted was the word "or"

    The code
    MyTable.SETFILTER(Field1, Value1);
    MyTable.SETFILTER(Field2, Value2);
    

    means field1=value1 and field2=value2.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • rsfairbanks
    rsfairbanks Member Posts: 107
    The required filter is 1n effect 3:
    Field1=Value1 and Field2=Value2
    Field1=Value1 and Fields2<>Value2
    Field1<>Value1 and Field2=Value2

    At each stage can copy to a temporary table/buffer and present this

    But all depends on your requirements and objectives.

    Apologies if I've missed the point
  • ara3n
    ara3n Member Posts: 9,258
    No problem, Yes temp table can be used.
    He can also use ADO and run the sql statement.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • canadian_bacon
    canadian_bacon Member Posts: 91
    You can also use the MARK function.
  • smic1983
    smic1983 Member Posts: 27
    Thank U Rashed,
    Can u just explain about ADO and how can i use the sql statement in CAL coding. Is it possible to get connection string directly from Navision itself. if its possible please pate sample code here.
    With Regards,
    Michael S.
  • ara3n
    ara3n Member Posts: 9,258
    Here is a howto to us ADO in NAV.

    viewtopic.php?f=5&t=23038&hilit=recordset


    And yes you can create the connection string from NAV. Almost all the info is available in session table. I'm assuming you are running on sql. The only you need is a separate login and pw which you can create in a setup table.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n