SETRANGE problem

srinivas.chittemsrinivas.chittem Member Posts: 142
Hi Mibusonians,

This is srinivas.chittem. Here is a small issue, but it has great difficulty.

For example i have Item no.'s 1 to 1000

Now i want to filter (1 to 10) , (90-100),(250-350) and some more in the middle at a time........

I used set filter like
         rec.setfilter("No.",'%1..%2',Item01,Item10);
         rec.setfilter("No.",'%1..%2',Item90,Item100);

Here problem is filter set Only once

I tried also like this
 rec.setfilter("No.",'%1..%2 |%3 ..%4',Item01,Item10,Item90,Item100);

Here no problem

suppose i have to filter 7 times in 7 different ranges...May i do this manually

Is there any Dynamic solution i have to give different types of range filters
in different situations
Regards,
srinivas
"Delighting Customers.... Through Delivery Excellence" .

Comments

  • McClaneMcClane Member Posts: 40
    Maybe you could set the first range you want, mark the found records, then set your 2nd range, mark them too and so on. When finished, set markedonly(true).
  • kapamaroukapamarou Member Posts: 1,152
    Your first attempt does not work since applying the filter on the field removes the previous filter on that field.

    One way is the way McClane suggested.

    Anotherthing you could do is the following.



    textFilter := 'Item01..Item10';
    textFilter := textFilter + '|';
    textFilter := textFilter + 'Item19..Item32';
    ....
    ...
    ..


    rec.setfilter("No.",'%1',textFilter);
  • DenSterDenSter Member Posts: 8,305
    The syntax for SETFILTER is: Record.SETFILTER(Field, String, [Value],...), where String represents the filter string. If you need a dynamic filter string, you will need to write a function that builds this string, and then applies it to the Record.
  • jlandeenjlandeen Member Posts: 524
    I've built functions to generate these types of filter strings in the past and there is one important caveat to keep in mind. There is a size limit to the string length that you can pass into the setfilter function (I think it's 250 Characters).

    So if you're building a filter string for a code 20 field and there are lots of values that are 20 characters in length. In that case you may only have 9 values in the filter before you hit the maximum.

    If there is a risk that the filters being built will hit this maximum then I use the record marking scenrio (or build a temporary recordset), which is slower then a set filter call. If the filters will be small then just use the setfilter function.
    Jeff Landeen - Sr. Consultant
    Epimatic Corp.

    http://www.epimatic.com
  • krikikriki Member, Moderator Posts: 9,110
    Hi Mibusonians,
    A nice one! :D:D
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • DenSterDenSter Member Posts: 8,305
    It would even be cooler if there were this museum like building that we all worked at called 'The Mibusonian Institute', with marble hallways and very high ceilings...
  • srinivas.chittemsrinivas.chittem Member Posts: 142
    As Mc Clane said is exactly correct...But, i marked the records which i want..

    But how to filter all marked records.?

    How to write the filter?
    Regards,
    srinivas
    "Delighting Customers.... Through Delivery Excellence" .
  • McClaneMcClane Member Posts: 40
    Like this:
    Item.SetFilter("No.",'A*'); // Find first Group
    if Item.find('-')then
      repeat
        Item.mark(true);
      until Item.next=0;
    
    Item.SetFilter("No.",'X*'); // 2nd Group
    if Item.find('-')then
      repeat
        Item.mark(true);
      until Item.next=0;
    
    // and so on ....
    
    item.SetFilter("No.",''); // clear Filter
    Item.MarkedOnly(true);
    form.runmodal(0,Item); // see all found&marked Items (here No. with first Character A or X)
    
Sign In or Register to comment.