数据库表大约有5000行,我想用下面代码打印出所有的行,当打印3行后,就跳到1000行打印,当打印到1003行之后就停止打印了,请问为什么?怎么解决?procedure TForm1.Button11Click(Sender: TObject);
var
  ifcontinue:bool;
  x,y:longint;
  hy:integer;
begin
   try
   x:=20;
   y:=200;
   printer.BeginDoc;
   with printer.Canvas do
   begin
    adoquery2.First;
    hy:=1;
    while (not adoquery2.Eof) do
    begin
    //y:=printer.Canvas.PenPos.Y;
    font.Name:='黑体';
    Font.Style:=[fsBold];
    font.Size:=13; //16
    //textout(x+250,y+50,inttostr(jsq)+'--****费清单');
    textout(x+250,y+50,inttostr(adoquery2.RecNo)+'--通话费清单');    font.Name:='宋体';
    Font.Style:=[];
    font.size:=12;
    textout(x,y+100,'┌─────┬─────┬─────────┬─────┬─────┬─────┐');
    textout(x,y+130,'│ 年度     │ 月份     │ 合同号           │ 用户名称 │  费用1   │费用2    │');
    textout(x,y+160,'├─────┼─────┼─────────┼─────┼─────┼─────┤');
    textout(x,     y+190,'│'+adoquery2.FieldByName('nd').AsString);
    textout(x+180, y+190,'│'+adoquery2.FieldByName('yf').AsString);
    textout(x+360, y+190,'│'+adoquery2.FieldByName('hth').AsString);
    textout(x+660, y+190,'│'+adoquery2.FieldByName('name').AsString);
    textout(x+840, y+190,'│'+adoquery2.FieldByName('fee1').AsString);
    textout(x+1020,y+190,'│'+adoquery2.FieldByName('fee2').AsString);
    textout(x+1200,y+190,'│');
    textout(x,     y+220,'└─────┴─────┴─────────┴─────┴─────┴─────┘');
    textout(x,     y+250,'打印日期:'+formatdatetime('yyyy-mm-dd hh:mm:ss',now));
    textout(x,y+350,     '**********************************************************************************');
    adoquery2.Next;
    if adoquery2.Eof then
       break;
    y:=y+430;
    hy:=hy+1;
    if hy=5000 then   //定义每页打印的记录数,我的要求是5000行记录全部打印完才让打印机换页,
    begin
       hy:=1;      //必须要有这4行
       printer.NewPage;
       X := 20;
       y := 200;
    end;
    end;
    end;
    printer.enddoc;
   except
    showmessage('打印机错误');
   end;
end;