Options

How can I filter a list form??...

demi222demi222 Member Posts: 131
I have Table A which has the following fields:

Code of type code 10
Description of type text 30
G/L Account Number with table relation to "G/L Account"."No."

The Primary key is Code and G/L Account Number.

so...this can be an example of some records:
Code........................Description........................G/L Account No.
EEEE...........................Description of EEEEE............12345678
EEEE...........................Description of EEEEE............33333333
EEEE...........................Description of EEEEE............55555555
FFFF............................Description of FFFFFF.............9999999
FFFF............................Description of FFFFFF.............8888888


I have made a List form from Table A which shows only Code and Description. This form is the LookupFormID for Table A.

On another form, I have a Textbox with a TableRelation to Table A, which has a source expression CCC, which is a Global Variable of text 30.

Now...

When I click on the Textbox's lookup button I want the List to show up without repeating ...for example...
I would want from the above the following to show up:
EEEE...........................Description of EEEEE
FFFF............................Description of FFFFFF

what shows up now is:
EEEE...........................Description of EEEEE
EEEE...........................Description of EEEEE
FFFF............................Description of FFFFFF
FFFF............................Description of FFFFFF


Is this possible? Can anyone help me?

Comments

  • Options
    s.delikostovs.delikostov Member Posts: 32
    The best way is to create a new table - Table B - with fields Code and Description.
    In table A you will use a TableRelation for filed Code using Table B.
    The SourceTable for List form will be the new table (Table B).

    Another way is to use temporary table in the List form.
    Stamen Delikostov
    Navision Solution Developer
    Intelligent Systems Bulgaria
  • Options
    demi222demi222 Member Posts: 131
    I don't want to have to make another table... how could I do it with a temporary table?
  • Options
    s.delikostovs.delikostov Member Posts: 32
    IF TableA.FIND('-') THEN REPEAT
      TableATemp.RESET;
      TableATemp.SETRANGE(Code,TableA.Code);
      IF NOT TableATemp.FIND('-') THEN BEGIN
        TableATemp.INIT;
        TableATemp.TRANSFERFIELD(TableA);
        TableATemp.INSERT;
      END;
    UNTIL TableA.NEXT = 0;
    
    FORM.RUNMODAL(ListForm,TableATemp);
    
    Stamen Delikostov
    Navision Solution Developer
    Intelligent Systems Bulgaria
  • Options
    kinekine Member Posts: 12,562
    edited 2005-07-21
      if TableA.FIND('-') then
      repeat
        TableA.MARK := true;
        TableA.SetFilter(Code,TableA.Code);
        TableA.Find('+');
        TableA.SetFilter(Code);
      until TableA.Next=0;
      TableA.MARKEDONLY := true;
      FORM.RUNMODAL(0,TableA);
    

    Another solution is to fill temp. table in same manner and show this virtual table. But BEST is (if something other is not problem than) - split the tables>

    Table A: Code + Description
    Table B: Code (linked to table A), G/L Account No. (Linket to GL Acc.), Description (lookup flowfield to table A)

    than you can made lookup to table A and you have correct list...
    (as s.delikostov wrote)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    demi222demi222 Member Posts: 131
    which trigger do I put this code in?
  • Options
    s.delikostovs.delikostov Member Posts: 32
    In the button where you run the List form
    Stamen Delikostov
    Navision Solution Developer
    Intelligent Systems Bulgaria
  • Options
    kinekine Member Posts: 12,562
    Or in OnLookup trigger... or you can modify it to work with Rec and insert it into the lookup form OnOpen... (without the FORM.RUNMODAL line)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    demi222demi222 Member Posts: 131
    s.delikostov,
    According to your code, TableA is a record variable to my table and TableATemp is a temporary record variable to the same table.
    When I do TableATemp.SETRANGE(Code,TableA.Code) the first code is Rec.Code right?
    Well... I tried this, and it didn't work... it didn't show the ones it is supposed to show. if there were
    Code...........Code Description........G/L Account
    AAA ............. AAA description........12344
    AAA...............AAA Description........33333
    BBB...............BBB Description........44444
    BBB...............BBB Description........55555
    CCC..............CCC Description........66666

    It only showed CCC nothing else.



    KINE,
    I tried yours...
    TableA is the temporary record variable of my table right? When I do
    TableA.SETFILTER(Code,TableA.Code) the first code is Rec.Code right?
    The second SETFILTER you have only has Code in it... that isn't right...???
    Should it be the same as the first SETFILTER?
  • Options
    s.delikostovs.delikostov Member Posts: 32
    Before
    FORM.RUNMODAL(ListForm,TableATemp);

    add the line:
    TableATemp.RESET;
    Stamen Delikostov
    Navision Solution Developer
    Intelligent Systems Bulgaria
  • Options
    kinekine Member Posts: 12,562
    The construction
        TableA.SetFilter(Code,TableA.Code);
        TableA.Find('+');
        TableA.SetFilter(Code);
    

    means, skip all next records with same Code as Now and than clear this filter... TableA.Next then go to next code...

    Oh, sorry, correction, the line must be
        TableA.SetRange(Code);  //SetRange instead SetFilter...
    
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    demi222demi222 Member Posts: 131
    Ok.. now it works... but something else is different now.

    I have a Textbox with SourceExpression lalala which is type Text 30
    and it has a Table relation to Table A....

    Now, when I click the lookup it opens the list form just as I wanted, but now, it doesn't let me double click on the item I want it to show.

    Before I put the code on the OnLookup trigger, it showed me everything, and I would simply double click on the one I wanted, and it would show it.

    How can I make that work again?
  • Options
    kinekine Member Posts: 12,562
    try to use this construction:
      if FORM.RUNMODAL(0,TableA) = Action::LookupOK then
    ...
    
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    demi222demi222 Member Posts: 131
    Before, when the List form opened, and I chose one of the items and double clicked,
    it would then put the rest of the information I wanted in the table box I have below the lookup text box...

    Now, do I put the code I had OnAfterGetRecord in the OnLookUp trigger?
  • Options
    kinekine Member Posts: 12,562
    In OnLookupTrigger is common C/AL structure this:
      <set filter to record (for example TableA)>
      TableA.SETRANGE("Field 5532",'VALUE I WANT');
      if FORM.RUNMODAL(0,TableA) = Action::LookupOK then begin
        <use TableA to read the selected record and assign values you need>
         VALIDATE("Field 1", TableA."Field 123");
      end;
    
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    demi222demi222 Member Posts: 131
    GREAT!!!
    Thanks a lot for all your help!!!
    I appreciate it!

    :D
Sign In or Register to comment.