SETFILTER Problem

AliBomberAliBomber Member Posts: 13
edited 2003-05-05 in Navision Attain
hI i've got a little problem with the setfilter function:
e.g.
I write the following down and run it:

REPEAT
SETFILTER(Ausprägung,'<>%1',constraint_Rec_Help.Ausprägung);
UNTIL constraint_Rec_Help.NEXT = 0;

Then my problem is, that the last setfilter function overwrites the other results. But I want that all filters which are set in repeat-until-loop will be set.
How can I solve that????
Thank You very much for help. :cry:

Comments

  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    You could build a string first that contains all your filters, and then use 1 SETFILTER with your string, eg.:

    txtString := '';
    i := 0;
    REPEAT 
      i := i + 1;
      IF txtString <> '' then
        txtString := txtString + "&";
      txtString := txtString + '<>%' + FORMAT(i) + constraint_Rec_Help.Ausprägung; 
    UNTIL constraint_Rec_Help.NEXT = 0;
    SETFILTER(Ausprägung,txtString);
    
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • AliBomberAliBomber Member Posts: 13
    Very cool idea, I'm gonna try it...
    Thank you for the fast response.. :P
  • Robert_EllsworthRobert_Ellsworth Member Posts: 19
    I'm having a problem related to SETFILTER, but it is a little different. Let's say I have a field - "No.", type CODE(2). I want to set the following filter on this code field:
    SETFILTER("No.", '%1|%2', '01', '75');
    

    Whenever I try to do that setfilter, i get an overflow error. Since the size of the field is 2 characters, is it possible to set a filter larger than 2 characters?[/code]
  • WaldoWaldo Member Posts: 3,412
    I tried to regenerate te problem with a new table:
    OBJECT Table 50000 Test
    {
      OBJECT-PROPERTIES
      {
        Date=30/04/03;
        Time=[ 8:15:17];
        Modified=Yes;
        Version List=;
      }
      PROPERTIES
      {
      }
      FIELDS
      {
        { 1   ;   ;Code                ;Code2          }
        { 2   ;   ;Description         ;Text30         }
      }
      KEYS
      {
        {    ;Code                                     }
      }
      CODE
      {
    
        BEGIN
        END.
      }
    }
    

    and codeunit:
    OBJECT Codeunit 50000 test
    {
      OBJECT-PROPERTIES
      {
        Date=30/04/03;
        Time=[ 8:18:51];
        Modified=Yes;
        Version List=;
      }
      PROPERTIES
      {
        OnRun=VAR
                recTest@1000000001 : Record 50000;
              BEGIN
                recTest.SETFILTER(Code,'%1|%2', '01','75');
              END;
    
      }
      CODE
      {
    
        BEGIN
        END.
      }
    }
    
    

    I did not get the error at all. May be you can redefine your problem, or give us more details about it?

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • AliBomberAliBomber Member Posts: 13
    The original problem was the following:
    I tried to run more than one setfilter functions on the same field. But only the last setfilter command was recognized, while the other ones seemed to be unrecognized. I had to put the setfilter in a repeat-until-loop...
    I solved the problem by first using the mark function and then I filtered only the marked records.
    This works well.
Sign In or Register to comment.