>Cetin,
>
>Thank you for your reply
>underneath you find the code.
>
>It used to be a part of an older foxpro 2.6 program. As far as i can see it should work fine, what it does most of the time. Not always.
>I have had already changed the code into 'INSERT INTO' (that's why most of it has '*' in front of it), because I thought the problem could be there, but it keeps popping up. So even with with this code I sometimes have empty records...
>
>
>
>
>the '$$' marks are inserted to comment the program for you
>
> sele consol
> set order to consol
>
>$$: of course order consol is on xsysnr + prj + dtos(datum)
>
> ** maak record bij als nodig is
> if !seek(hp_ad.xsysnr+hp_ad.prj+dtos(hp_ad.datum))
>
>$$ : this is the problem-spot: append blank is always executed, but the replace command fails, sometimes. But: if you open the table with order 'consol' this record is shown in the sequence on the place it would have to have had when the fields 'dag', 'project' and 'xsysnr' were replaced normally. My conclusion is: the index was updated but the fields not, because they are empty...
>
> *append blank
> * if rlock()
> * replace dag with hp_ad.datum,;
> * project with hp_ad.prj,;
> * xsysnr with hp_ad.xsysnr
> * unlock
> * endif
> * sele pers
> * if seek(hp_ad.xsysnr)
> * sele consol
> * if rlock()
> * replace naam_op with alltrim(pers.naam)+ ', ' + alltrim(pers.vnaam)
> * unlock
> * endif
> * endif
> *sele consol
>
> ** plaats in pers op juiste
> sele pers
> seek(hp_ad.xsysnr)
>
> sele consol
> insert into consol (dag,project,xsysnr,naam_op);
> values (hp_ad.datum,hp_ad.prj,hp_ad.xsysnr,alltrim(pers.naam)+ ', ' + alltrim(pers.vnaam))
>
>
> endif
>
>
>Best regards
>Ivo
"My conclusion is: the index was updated but the fields not, because they are empty...". Regarding to your sentences I wonder if you're appending to "consol" when hp_ad is at eof() ? Revised the code some, try with this.
if eof()
wait window "At EOF()"
return
endif
if empty(hp_ad.xsysnr) ;
or empty(hp_ad.prj) ;
or empty(hp_ad.datum)
wait window nowait "Warning! Empty field(s) in hp_ad"
endif
cSeekExpr = padr(hp_ad.xsysnr,fsize("xsysnr","consol") + ;
padr(hp_ad.prj,fsize("prj","consol")) + dtos(hp_ad.datum)
if !seek(cSeekExpr,"consol","consol")
m.naam_op = iif(seek(hp_ad.xsysnr,"pers"),;
alltrim(pers.naam)+ ', ' + alltrim(pers.vnaam),"")
insert into consol (dag, project, xsysnr,naam_op) ;
values (hp_ad.datum, hp_ad.prj, hp_ad.xsysnr, m.naam_op)
endif
Cetin