3.60 filtering problem

I recently upgraded from 2.60 to 3.60. I have Code20 field. When I run a list form with this table and apply a field filter ‘<>RISK MITIGATION&<>RISK ASSESS’ everything works fine. If I do the same in code: SETRANGE(MyCode20Field, ‘<>RISK MITIGATION&<>RISK ASSESS’) I get and error:“The value in the filter ‘<>RISK MITIGATION&<>RISK ASSESS’ in the MyCode20Field field in the table is too long for the field type. Type: Code20” SETFILTER gives the same error message.

it seems strange that you get an error. ive tried that once and filtering for <>SUBSTRING* does not work. ive filtered document no. in the sales shipment header for “<>DDT*” and got the same result as ive i hadnt filtered at all.

Hello, I cannot seem to replicate this in 3.60, but I can in 3.70. You might want to look at the form to see if there is a GetSelectionFilter or GetCaption function in the form. This might be what is causing the problem.

Hi Stefan The SETRANGE will not work. The Setrange syntax is SETRANGE(Field,FromValue,ToValue) so you are selecting a specific range. You could try this for the SETFILTER. SETFILTER(MyCode20Field,’<>%1&<>%2’,‘RISK MITIGATION’,‘RISK ASSESS’);

Thanx stepheng Of course SETRANGE will not work (I’ve only been programming in Navision for six years, how should I know [xx(]). The problem is I’m using SETFILTER and I get that error. I tried the same code on the Customer card in an unchanged Cronus database and didn’t get the error. I’m guessing it has something to do with the form like EBloom suggested.

SETFILTER(MyCode20Field,’<>%1&<>%2’,‘RISK MITIGATION’,‘RISK ASSESS’); works fine but the filterstring is actually user-defined in a setup table.

Stefan I’m guessing that the user fills in a field in the setup table with the filter, eg Table-SetupTable Field-UserFilter. So you could try this. SETFILTER(MyCode20Field,SetupTable.UserFilter);

I think I’m being a nitwit. I rewrote the code and its working fine now.[?]

Okay you are a nitwit :wink: but what’s the solution?