Filtering a table with a field option having only a text 1

andy76andy76 Member Posts: 616
Hello,

I have this strange problem

I have a table called 'Table1' with a field called 'Field1' of type Option having these options for example:

A - djfaksdfj
B - kdfjsdkfj
C - jfklsdj

in my code I have a variable called 'Variable1' of type Text 1 containing only the first letter of option taken by other tables and calculation

For example I have Variable1:='A'

Which is the better way to filter 'Table1'

Something similar to Table1.SETFILTER(Field1,'%1',Variable1 +'*') but doesn't go...error..

Thank you very much

Comments

  • kinekine Member Posts: 12,562
    1) Better will be to have integer - the position of the value in the option string (zero based) - than you can filter on this integer (A = 0, B = 1) etc.

    2) Because the option have limited count of values, to map the values you can use the CASE:
    case Variable1 of
    'A': Table1.SETRANGE(Field1, Table1.Field1::"A - djfaksdfj");
    'B': Table1.SETRANGE(Field1, Table1.Field1::"B - kdfjsdkfj");
    'C': Table1.SETRANGE(Field1, Table1.Field1::"C - jfklsdj");
    end;
    
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
Sign In or Register to comment.