hI i’ve got a little problem with the setfilter function: e.g. I write the following down and run it: REPEAT SETFILTER(Ausprägung,’<>%1’,constraint_Rec_Help.Ausprägung); UNTIL constraint_Rec_Help.NEXT = 0; Then my problem is, that the last setfilter function overwrites the other results. But I want that all filters which are set in repeat-until-loop will be set. How can I solve that??? Thank You very much for help.
Please elaborate on what do u want to do so as we can assist you. [;)] What do you want to filter?
First thing: Your filter in that loop has no sense at all… let me explain you why: Let’s say you just have three records: constraint_rec_help.Auspragung is A in the first one, B in the second one and C in the third one… so you’re having the following: 1 - A 2 - B 3 - C When you set the filter on the first one, you say that you’re having all records where the Auspragung is not A ( <>A), so you’re having records 2 and 3. On your second time in the loop you set the filter to all the records that are different from B ( <>B) so you’re getting records 1 and 3… if you continue the loop on step 3 you get that you get the records 1 and 2… so at the end if you want all the filters result you’re having all records… If i’m not wrong what you try to do is getting all the records excepting the ones that match those conditions… something like ( <>A AND <>B AND <>C). An easy way for you to do it is by using mark… something like this will work Ubut the process will take a bit more…):
Aux_Constraint_rec_help.RESET; Aux_constraint_rec_help.CLEARMARKS; IF (Aux_Constraint_rec_help.FIND('-')) THEN REPEAT Aux_constraint_rec_help.MARK(TRUE); UNTIL (Aux_constraint_rec_help.NEXT = 0); IF (Constraint_rec_help.FIND('-')) THEN REPEAT Aux_constraint_rec_help.SETRANGE(Ausporagung,Constraint_rec_help.Auspragung); if (aux_constraint_rec_help.FIND('-')) THEN REPEAT Aux_constraint_rec_help.MARK(FALSE); UNTIL (Aux_constraint_rec_help.NEXT = 0); UNTIL (Constraint_rec_help.NEXT =0); Aux_constraint_rec_help.MARKEDONLY(TRUE); That way you’ll keep on Aux_constraint_rec_help all the records not matching any of those conditions… Hope that helps you, Regards,
Hi Perhaps a second loop does the job:
constraint_Rec_Help.SetRange(constraint_Rec_Help.YourField,YourFilter); If constraint_Rec_Help.Find('-') Then; REPEAT Rec.SETFILTER(Rec.Ausprägung,'<>%1',constraint_Rec_Help.Ausprägung); Rec.Find('-'); Repeat YourCode Until Rec.Next = 0; UNTIL constraint_Rec_Help.NEXT = 0; bye André
Andre… if what he’s wanting is to run a code if his records field is not in the set of records he’s having filtered… (let’s say he’s having on constraint_rec_help records 1, 2 and 3 with values on Auspragung A,B and C. If he’s wanting to do his code on all records where the values are not A,B,C with your code he’ll run the code on items where the value is not A (but could be B and C) then on the ones that are not having it’s value equal to B (that’s also the ones you skip previously as their value was A). Check my previous example on the previous post and you’ll see an example on how to do something like what he pretends… just remove the “Aux_Constraint_rec_help.” variable from the example and remove also the “Aux_Constraint_rec_help.reset” line and you’ll have the code working in the actual set of records he was using (Rec). Regards,
I think he is trying to set a range of filters from table 1 to table 2 IF constraint_Rec_Help.FIND(’-’)then REPEAT MyFilter := constraint_Rec_Help.Ausprägung; IF constraint_Rec_Help.NEXT <> 0 THEN MyFilter := MyFilter + ‘|’; UNTIL constraint_Rec_Help.NEXT = 0; Then Your Filter would be ‘Value1|Value2|Value3|Value4’ Then apply the filter to your table Table2.SETFILTER(Ausprägung,’<>%1’,MyFilter);
David… i didn’t tried your code… but if you replace %1 with Value1|Value2|Value3|Value4 the fillter will be: SETFILTER (Auspragung,’<>Value1|Value2|Value3|Value4’) that translated to results will be all the records that are not Value1 and are Value2, Value3 or Value4… The filter in that way should be something like (<>Value1)&(<>Value2)&(<>Value3)&(<>Value4) The problem as usual is the lenght of that filter… as he’s reading a set of records and that set can give a longer size on the text than the 1024 chars that Attain is allowing and longer than the 260 chars financials is allowing also… Regards,
Originally posted by apertierra
David… i didn’t tried your code… but if you replace %1 with Value1|Value2|Value3|Value4 the fillter will be: SETFILTER (Auspragung,’<>Value1|Value2|Value3|Value4’) that translated to results will be all the records that are not Value1 and are Value2, Value3 or Value4…
Maybe it should be ‘<%1>’ to give us ‘<Value1|Value2|Value3|Value4>’ as the code suppied is not equal to constraint_Rec_Help.Ausprägung REPEAT SETFILTER(Ausprägung,’<>%1’,constraint_Rec_Help.Ausprägung); UNTIL constraint_Rec_Help.NEXT = 0; I think we need a better idea of what Uhlig is trying to Achive. Regards
Dear People, thank for your help. The best idea, and the only one that really works, is the one using the mark-method. This way is very easy and fast to implement. The other solutions, e.g. concatenation of string etc, lead to run time errors. Markus
Hi I’ve just joined and I find the content of this user group very informative. I have come across a problem in Navision for which I cannot find a workaround. Basically it inolves using the ‘<>’ sign with a filter that contains a wildcard(). Example: I want to filer out Item No’s on a report to exclude Item No.'s starting with the prefix ‘FIN’. If I type: ‘<>FIN-001’, Navision does filter out this item correctly. But if I type: '<>FIN’, Navision returns ALL records, i.e. it will ignore the filter. As far I know, such a filter is completely valid. Why does Navision have a problem with it? David T
Hi David, try it with temp := ‘fin*’; SETFILTER(, ‘<>%1’, temp); where is the name of the Field you want to set a filter. This should do the work. Greetings, Frank