Create new records from report

Hi everybody, In a personalized module in N/F 2.6 I want to create a report which first runs thruough all the rental contracts and on basis of these will issue free rental vouchers. These rental vouchers should be numbered and saved in a table and then printed. My problem is that I can insert the first record in the voucher table but after that a new record is not created. The code I am using: IF HocVoucher.“Cód. voucher” = ‘’ THEN BEGIN ConfVtas.GET; ConfVtas.TESTFIELD(ConfVtas.“Nº serie Hoc voucher”); HocVoucher.INIT; GestNoSer.InicSerie(ConfVtas.“Nº serie Hoc voucher”,ConfVtas.“Nº serie Hoc voucher”,0D, HocVoucher.“Cód. voucher”,ConfVtas.“Nº serie Hoc voucher”); HocVoucher.INSERT; END; I have seen the subjects in the forum concerning the f3 key etc. but it doesn’t help me. Any ideas please? Thanks

If you want to read entries in a table, and then create new entries in the same table under certain conditions, I would define a local variable which you use to do the insert: IF HocVoucher.“Cód. voucher” = ‘’ THEN BEGIN ConfVtas.GET; ConfVtas.TESTFIELD(ConfVtas.“Nº serie Hoc voucher”); lrecHocVoucher.INIT; GestNoSer.InicSerie(ConfVtas.“Nº serie Hoc voucher”,ConfVtas.“Nº serie Hoc voucher”,0D, lrecHocVoucher.“Cód. voucher”,ConfVtas.“Nº serie Hoc voucher”); lrecHocVoucher.INSERT; END By doing that, you do not interfere with the sequence of reading the HocVoucher table. Regards, Andy

Hi Andy, Thanks for your reply. But I still have the same problem. If the system should create say 5 vouchers, the above code will be accessed 5 times, but it still only creates 1 record in the table, as a new line is not inserted after creating this first record. Regards Soren

…And you get no insert error? Did you verify that the insert is performed every time, using the debugger? If you have no error on insert, the code probably runs the IF condition one time only. Where is the code placed in the report? I mean, in which trigger?

I made the code easier to read : IF HocVoucher."Cód. voucher" = '' THEN BEGIN ConfVtas.GET; ConfVtas.TESTFIELD(ConfVtas."Nº serie Hoc voucher"); HocVoucher.INIT; GestNoSer.InicSerie(ConfVtas."Nº serie Hocvoucher", ConfVtas."Nº serie Hoc voucher", 0D, HocVoucher."Cód. voucher", ConfVtas."Nº serie Hoc voucher"); HocVoucher.INSERT; END; Why not use step-by-step debugger ? there is only 1 case that insert will not create a new record : ’ IF HocVoucher.“Cód. voucher” = ‘’ THEN ’ does not work because after insert the field ‘HocVoucher.“Cód. voucher”’ is filled ! your INIT then is to late to clear the field so i would solve it like : IF HocVoucher."Cód. voucher" = '' THEN BEGIN ConfVtas.GET; ConfVtas.TESTFIELD(ConfVtas."Nº serie Hoc voucher"); HocVoucher.INIT; GestNoSer.InicSerie(ConfVtas."Nº serie Hocvoucher", ConfVtas."Nº serie Hoc voucher", 0D, HocVoucher."Cód. voucher", ConfVtas."Nº serie Hoc voucher"); HocVoucher.INSERT; HocVoucher."Cód. voucher" := ''; // NEW END;

Hi domenico and iammicky, Thank you very much for your help. The line: “HocVoucher.“Cód. voucher” := ‘’; // NEW” did the trick and it is working now. Regards Soren Hansen