Filter max length

mabl4367mabl4367 Member Posts: 143
I have a report that builds a string to be used as a filter for the item no. field.

Is there a limit for how long a filter can be?

If so I'd like to make my report handle it in a nice way.

Answers

  • kapamaroukapamarou Member Posts: 1,152
    There is a limit (I don't remember exactly how many chars). There are three solutions (the third I think is the best...)

    1. Build the filter in the form A|C..K|Z.
    2. Use MARK.
    3. Use a temporary table to store the records you want. Then an
    IF TempRec.GET(KeyValue) THEN BEGIN
    END;
    is like a filter...
  • DenSterDenSter Member Posts: 8,304
    I believe the maximum filter string length is 250 characters. The issue of over flowing filterstring happens a lot when it is built in code like that. You'll need to program a check to make sure it doesn't go over.
  • garakgarak Member Posts: 3,263
    as i know the maxlenght is ~ 440.
    for i := 1 to 1024 do begin
      if Strlen(Filtercode) = 0 then
        Filtercode := format(i)
      else begin
        if strlen(Filtercode + '|' + format(i)) <= 440 then
          Filtercode := Filtercode + '|' + format(i);
      end;
    end;
    message(format(strlen(Filtercode)));
    Item.setfilter("No.",Filtercode);
    Form.runmodal(0,Item);
    

    Regards
    Do you make it right, it works too!
  • mabl4367mabl4367 Member Posts: 143
    250 characters.... I think I've heard that somewhere else to. But if Garak is right its around 440.

    Perhaps 250 chars are guarantied to work and larger filters may work under special circumstances.

    It would be good to know the exact maximum number of characters guarantied to work and even better to know why.
  • DenSterDenSter Member Posts: 8,304
    So build a filter string, one character at a time, and set it as the filter. When it errors out, you will know the answer.

    By the way, 440 does not sound right to me. I remember getting errors as soon as the length hits 250. It might have changed though. One way to find out: test it.
  • garakgarak Member Posts: 3,263
    With the test code snippes above, the filterstring on Item no is >250. It's 439.
    Maybe the problem in older versions was the Variable lenght of 250.
    Now it's max 1024.
    Also possible, that MS has changed the max. Filtercriteria parameter.

    regards
    Do you make it right, it works too!
  • mabl4367mabl4367 Member Posts: 143
    OK

    Thank you all for your help. I'll stay under 250 chars and I'll be ok. :D
  • kapamaroukapamarou Member Posts: 1,152
    Just be careful... Item No. is 20 chars. It can easily get out of range... :wink:
Sign In or Register to comment.