problem with leading blank

Hi all, i have a problem with the Post Code table, in the field City there is always a blank as first character. so i wrote a little codeunit : IF rec225a.FIND(’-’) THEN REPEAT IF rec225a.GET(rec225a.Code,rec225a.City) THEN BEGIN rec225a.RENAME(rec225a.Code,COPYSTR(rec225a.City,2,STRLEN(rec225a.City))) ; END; UNTIL rec225a.NEXT = 0 ; MESSAGE(‘done’); but guess what ! i doesnt work like it should! most of the city-names are modified correctly, but others remain the same with the blank :frowning: what am i doing wrong here??? thanks in advance Frank

Frank, I don’t know what version you are working in, but I think the Post Code table only has one key field : Code. I think you want to have something like this: IF PostCode.FIND('-') THEN REPEAT IF PostCode.City[1] = '' THEN BEGIN // or IF PostCode.City[1] = ' ' THEN BEGIN PostCode.City := COPYSTR(PostCode.City,2); PostCode.Modify; END; UNTIL PostCode.NEXT = 0; Course not of your City values start with a ‘’ (due to previous batch) you will need to check this. * Code has not been tested. BTW, Why the strange recordnames?

the postcode table has got a double key, code and city, because it’s the belgian version (and here we can have for the same code, 2 citynames, one dutch and one french :-))

Hi Emiel Glad to see your back. Version 3.70 GB The primary key on the “Post Code” table is <Code,City>

Another thing is that, when you rename your record Navision automatically reorder it. So try another solution: IF rec225a.FIND(’-’) THEN REPEAT IF rec225b.GET(rec225a.Code,rec225a.City) THEN BEGIN rec225b.RENAME(rec225b.Code,DELCHR(rec225b.City,’<>’,’ ')); END; UNTIL rec225a.NEXT = 0 ; MESSAGE(‘done’); Explanation: 1. Consider rec225a and rec225b - due to auto reorder 2. DELCHR is better than COPYSTR

thx ! works perfectly !