OR Filter on Forms

ta5ta5 Member Posts: 1,164
Dear experts
I have a special form which needs to have 2 filters for security reasons. The problem is, that both filters are independent. For example only records with Field1 = 'x' OR Field2='y' must be shown. How can this be achieved?
Thanks in advance
Thomas

Comments

  • SogSog Member Posts: 1,023
    temporary table.
    filter set 1 on the record, insert them into the temporary table, then unset filter 1, set filter 2 and add those if you don't find them.
    Ie:
    setfilter(field1,'x');
    if findset then
    repeat
      temptable.setrange(primary key field,rec."primary key field");
      temptable.setrange(primary key field 2,rec."primary key field 2");
      if temptable.isempty then begin
         temptable.copy(rec);
         temptable.insert;
      end;
    until next = 0;
    imagine what will be next
    
    |Pressing F1 is so much faster than opening your browser|
    |To-Increase|
  • ta5ta5 Member Posts: 1,164
    Hi Sog
    Thanks for quick reply.
    It's a ledger entry table, I think it's too slow. What do you think?
    Thomas
  • FlowerBizFlowerBiz Member Posts: 34
    I did something similar but it's not a simple solution. For large tables, the only way I know how to accomplish this efficiently is to create a new boolean field and assign its value in the OnInsert and OnModify table triggers. No need to use the MARK function or temporary tables. However, it only works if the conditions are static, since you have to hardcode them.

    You may or may not need to add this new boolean field to an index, depending on the distribution of the values amongst the data (performance monitoring and/or your user base will tell you).

    Dave
  • David_SingletonDavid_Singleton Member Posts: 5,479
    ta5 wrote:
    Dear experts
    I have a special form which needs to have 2 filters for security reasons. The problem is, that both filters are independent. For example only records with Field1 = 'x' OR Field2='y' must be shown. How can this be achieved?
    Thanks in advance
    Thomas

    I have a scenario which is possibly the same as yours, basically a user can see item ledger entries if they were sold to their customer, so there is a field "Sales Rep." also a person in charge of a location can see entries for this there is a field "Sales Location" both fields link to the sales person table. Now there is a new field something like "Security filter" := "Sales Rep." + '|' + "Sales Location". So applying a filter to this new field gives an "OR" filter.

    We had to do a lot with indexing and testing to make it work OK, but in the end its pretty fast. though its a pretty small database (approx 40gig) so not sure how it would go on a big one.
    David Singleton
Sign In or Register to comment.