Filter

kangal74kangal74 Member Posts: 15
Hi

I need to create a filter for my table.
I have 2 field ( famille, type ) and i want to filter only the record where the 2 fields have the same value.

I try this , and thats dont work:

Table.SETRANGE(Table.Famille,Table.type);

Best regards


Kangal

Comments

  • mohana_cse06mohana_cse06 Member Posts: 5,504
    May I know where did you write above code?
    and where do you need this? form/report?
  • kangal74kangal74 Member Posts: 15
    It s on form .

    I try several position to place the text.

    I need it on the onopenform and on the onlookup

    I try this on the onlookup:

    FormFamille.LOOKUPMODE := TRUE;
    FormFamille.EDITABLE := FALSE;
    SETFILTER(Type,Famille);
    IF FormFamille.RUNMODAL = ACTION::LookupOK THEN BEGIN
    FormFamille.GETRECORD(Rec);
    END;
    CLEAR(FormFamille);
    CurrForm.UPDATE(FALSE);

    dont work .
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    May I know exact requirement? so that we can suggest someother work around..
  • MarkHamblinMarkHamblin Member Posts: 118
    If you're using the form variable approach, you need to set the table view. E.g.,

    FormFamille.LOOKUPMODE := TRUE;
    FormFamille.EDITABLE := FALSE;
    SETFILTER(Type,Famille);
    FormFamille.SETTABLEVIEW(Rec);
    IF FormFamille.RUNMODAL = ACTION::LookupOK THEN BEGIN
    ...
  • kangal74kangal74 Member Posts: 15
    If you're using the form variable approach, you need to set the table view. E.g.,

    FormFamille.LOOKUPMODE := TRUE;
    FormFamille.EDITABLE := FALSE;
    SETFILTER(Type,Famille);
    FormFamille.SETTABLEVIEW(Rec);
    IF FormFamille.RUNMODAL = ACTION::LookupOK THEN BEGIN
    ...
    That s dont work, the table are not filtered.

    IF I use Setrange , the table are filtered but with the '' value.
    Thats dont work.

    Another idea ?
    Best regards
  • thmartinthmartin Member Posts: 90
    If I understand you correctly you want to only see the records where 2 different fields have the same value in the same record.

    Like in this example:

    famille type
    Record1 A A <----
    Record2 B A
    Record3 C C <----

    In that case you have to read every single record.
    You could work with marks like in this post:
    http://www.mibuso.com/forum/viewtopic.php?f=14&t=2673

    Or you could work with a temporary table.
    Thomas Martin
    NAV Developer
  • ppavukppavuk Member Posts: 334
    This could be very useful to read some manuals in order to get some understanding how setrange and setfilter works before asking :)
  • MarkHamblinMarkHamblin Member Posts: 118
    And also nicer ways to access look-ups. Here's some sample code that does what you need, but based on the sales header table. It looks up any sales headers of type "Order", and is much nicer syntax than using the form variable like you're trying to do.

    SalesHeader.SETRANGE("Document Type", SalesHeader."Document Type"::Order);
    IF FORM.RUNMODAL(FORM::"Sales List", SalesHeader) = ACTION::LookupOK THEN
    MESSAGE(SalesHeader."No.");
Sign In or Register to comment.