Z
zhao753
Unregistered / Unconfirmed
GUEST, unregistred user!
我在编写报表时遇到一难题,如下:
在form1中有一Button,事件如下,即单击此按钮将显示一报表(form2)的预览.
procedure TForm1.Button1Click(Sender: TObject);
var s:string;
begin
s:='select mlno,text,paixu,sangxing,xiaxing,xiaxing1,xiaxing2,xiaxing3 from want_print_ds where meet_id=''4'' and shangxiaxing like ''1T%'' order by gongli';
ADOQuery1.sql.Clear;
//showmessage('ok');
ADOQuery1.sql.add(s);
ADOQuery1.Open;
ADOQuery1.Active:=true;
form2.quickrep1.Prepare;
form2.quickrep1.preview;
end;
在form2中,由于一字段值过长,所以用如下代码使之自动折行,并使其高度随此字段长度而定.
procedure TForm2.QRDBText3Print(sender: TObject;
var Value: String);
var i,l,w,h,p:integer;
s,cs:string;
begin
s:='';
i:=0;
l:=0;
w:=0;
p:=1;
l:=length(trim(value));
w:=trunc((QRDBText3.Width-2)/12*2)-36;
while pos(#13#10,value)>0do
begin
delete(value,pos(#13#10,value),2);
next;
end;
while pos(' ',value)>0do
begin
delete(value,pos(' ',value),2);
next;
end;
if l<=W then
QRDBText3.Height:=-Font.Height+10
else
if l>w then
begin
h:=trunc(l/w);
if l>h*w then
h:=h+1;
cs:=copy(value,1,w);
QRDBText3.Height:=-Font.Height *h+(h-1)*10;
for i:=1 to hdo
begin
cs:=copy(value,p,w);
if bytetype(cs,w) = mbTrailByte then
begin
// 整个汉字
cs:=copy(value,p,w);
p:=p+w;
end
else
//半个汉字
begin
cs:=copy(value,p,w-1);
p:=p+w-1;
end;
s:=s+cs+#13#10;
end;
value:=s;
end;
DetailBand1.Height:=QRDBText3.Top+QRDBText3.Height;
end;
可是,每次执行若干次单击Button1时却出现如下错误:
Access Violation at address 0040D3BA in module 'project1.exe'. read of address 00E38006.
请教高手如何解决,将全部家当奉上!!!!
在form1中有一Button,事件如下,即单击此按钮将显示一报表(form2)的预览.
procedure TForm1.Button1Click(Sender: TObject);
var s:string;
begin
s:='select mlno,text,paixu,sangxing,xiaxing,xiaxing1,xiaxing2,xiaxing3 from want_print_ds where meet_id=''4'' and shangxiaxing like ''1T%'' order by gongli';
ADOQuery1.sql.Clear;
//showmessage('ok');
ADOQuery1.sql.add(s);
ADOQuery1.Open;
ADOQuery1.Active:=true;
form2.quickrep1.Prepare;
form2.quickrep1.preview;
end;
在form2中,由于一字段值过长,所以用如下代码使之自动折行,并使其高度随此字段长度而定.
procedure TForm2.QRDBText3Print(sender: TObject;
var Value: String);
var i,l,w,h,p:integer;
s,cs:string;
begin
s:='';
i:=0;
l:=0;
w:=0;
p:=1;
l:=length(trim(value));
w:=trunc((QRDBText3.Width-2)/12*2)-36;
while pos(#13#10,value)>0do
begin
delete(value,pos(#13#10,value),2);
next;
end;
while pos(' ',value)>0do
begin
delete(value,pos(' ',value),2);
next;
end;
if l<=W then
QRDBText3.Height:=-Font.Height+10
else
if l>w then
begin
h:=trunc(l/w);
if l>h*w then
h:=h+1;
cs:=copy(value,1,w);
QRDBText3.Height:=-Font.Height *h+(h-1)*10;
for i:=1 to hdo
begin
cs:=copy(value,p,w);
if bytetype(cs,w) = mbTrailByte then
begin
// 整个汉字
cs:=copy(value,p,w);
p:=p+w;
end
else
//半个汉字
begin
cs:=copy(value,p,w-1);
p:=p+w-1;
end;
s:=s+cs+#13#10;
end;
value:=s;
end;
DetailBand1.Height:=QRDBText3.Top+QRDBText3.Height;
end;
可是,每次执行若干次单击Button1时却出现如下错误:
Access Violation at address 0040D3BA in module 'project1.exe'. read of address 00E38006.
请教高手如何解决,将全部家当奉上!!!!