SETFILTER and FIND

Hi,

I built a code where I use a SETFILTER and the FIND function

CurrRec.SETFILTER(No,0)

IF CurrRec.FIND(’-’) THEN

REPEAT

MESSAGE(FORMAT(CurrRec.“Line No.”));

UNTIL CurrRec.NEXT=0;

However when I display the first instance in a message box, I do not find the value I have in my record. I have instead a null result …

I do not understand why I cannot get the first row …

Thanks for your help

The filter looks correct to me, so if you get a message with nothing in it, there must be a record with a blank value in that filter. When strange things like this happen to me I usually open the table directly from the object designer, and manually set the same filters, to make sure I am looking at the same records.

That was my first action to check if the filter would be correct. My table looks like this:

No ¦ Line No ¦ Value ¦ …

0 ¦ 1 ¦ XXXX ¦ …

0 ¦ 2 ¦ YYYY¦ …

0 ¦ 3 ¦ ZZZZ ¦ …

I thought at the beginning that it could be the number - 0 - then I changed that by another one but still occuring .

I found out an explanation which would be identical with my problem :

http://mbs-navision.blogspot.com/

" … The code FIND (’-’) , will cause Navision to alway delete the first line. So what we can do here is to change FIND (’-’) to FIND (’=’). … "

Nevertheless I used FIND(’=’) instead of FIND(’-’) but without convincing results [:(] …

FIND(’-’) does not delete anything, it only retrieves records.

Try CurrRec.SETFILTER(No,’=0’);

Try CurrRec.SETFILTER(No,’=%1’,FORMAT(0));

Try CurrRec.SETRANGE(No,0);

Agree with DenSter. FIND(’-’) definitely won’t delete the first record. Instead, it will return the first record to you.

I tried what DenSter wrote but it does not work. You are right when you said that it does not delete, actually It seems to be an offset in my column, the first row is empty and the next one contains value whose the first line should have.

InterfaceLine.SETFILTER(“Batch No.”,‘0’);

IF InterfaceLine.FIND(’-’) THEN

REPEAT
CurrencyRate.SETFILTER(“Currency Code”,InterfaceLine.“Currency Code”);
IF CurrencyRate.FIND(’+’) THEN
Rate := CurrencyRate.“Relational Adjmt Exch Rate Amt” / CurrencyRate.“Exchange Rate Amount”;
“Value (Portfolio Currency)” := ROUND(InterfaceLine.“Value (Inv. Currency)” * Rate);
InterfaceLine.MODIFY;

UNTIL InterfaceLine.NEXT = 0;

I have understood my error. This error is provoked because I am doing a loop in the OnAfterImportRecord trigger that it was not necessary. I thought that the code started after all imports are done but the trigger modify only record by record. Then I removed this REPEAT… UNTIL and now there was no more offset !!! My mistake … [:D] Hope that my misunderstanding will help other beginners . Thanks