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

demi222
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?
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?
0
Comments
-
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.
Another way is to use temporary table in the List form.Stamen Delikostov
Navision Solution Developer
Intelligent Systems Bulgaria0 -
I don't want to have to make another table... how could I do it with a temporary table?0
-
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 Bulgaria0 -
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)0 -
which trigger do I put this code in?0
-
In the button where you run the List formStamen Delikostov
Navision Solution Developer
Intelligent Systems Bulgaria0 -
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)0
-
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?0 -
Before
FORM.RUNMODAL(ListForm,TableATemp);
add the line:
TableATemp.RESET;Stamen Delikostov
Navision Solution Developer
Intelligent Systems Bulgaria0 -
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 beTableA.SetRange(Code); //SetRange instead SetFilter...
0 -
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?0 -
try to use this construction:
if FORM.RUNMODAL(0,TableA) = Action::LookupOK then ...
0 -
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?0 -
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;
0 -
GREAT!!!
Thanks a lot for all your help!!!
I appreciate it!0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions