Fast Report 5
Hello, and I have this kind of problem
When I am trying to view (crtl+P) report, it always says that "Could not convert variant of type (NULL) into type (Integer)"
How I fix this problem?
When I am trying to view (crtl+P) report, it always says that "Could not convert variant of type (NULL) into type (Integer)"
How I fix this problem?
Comments
Can someone help? This is very annoying problem. Almost every report do this.
The root cause of your problem is that one or more Fields in the Table / Query driving your report has a Null value and is being passed to a non-variant Variable which can't convert it.
You need to break your problem down in order to solve it.
Can you view the data in the Table or returned by the Query to check for any unexpected Null values?
Can you run your report in "debug" mode to check exactly which part of FastReport is "failing"? (BeginDoc, BeforePrint
for the Report, or BeforePrint for the Header, Footer, Bands etc.)
At the very least you should provide more data here, such as what you've done so far to track this down, what other reports you have (that are working) and how this one differs from them.
Cheers, Paul
How I run it for "debug" mode?
And I have trying several reports (about 10-15 reports) and none of them not working. Always same error or some other error from NULL value. I havent make none of those reports so thats why it is a little challenging to find what is the root of error
from the ide environment
Sorry if this sounds vague, and long-winded, but we need a "way in" to help with the debugging...
Function Rivitetty(Teksti: String): String;
var
posi : Integer;
output, rivitetty, erotin : String;
begin
erotin := '$RVaihto';
output := Teksti;
rivitetty := '';
posi := Pos(erotin,output);
while posi > 0 do
begin
rivitetty := rivitetty +Copy(output,1,posi-1)+#10;
Delete(output,1,posi+(Length(erotin)-1));
posi := Pos(erotin,output);
end;
rivitetty := rivitetty +output;
Result := rivitetty;
end;
procedure Alusta;
var
Tarjous: Integer;
KieliSQL: String;
begin
Tarjous := Get('Tarjous');
KieliSQL := Get('KieliSQL');
adsKieli.SQL.Clear;
adsTarjous.SQL.Clear;
if Get('Kuva') then
begin
Picture1.Parent := PageHeader1;
Picture1.Visible := true;
Picture1.FileLink := Get('KuvaOs');
Picture1.Left := 0.4;
Memo1.Visible := false;
Memo2.Visible := false;
Memo3.Visible := false;
Memo4.Visible := false;
Memo99.Visible := false;
end;
adsKieli.SQL.Add(KieliSQL);
adsTarjous.Sql.Add('select T.*, ISNULL(M.Muistio,'+#39#39+') AS Muistio, R.Nimikekoodi, R.Nimike, R.Maara, R.Yksikko, ');
adsTarjous.Sql.Add('aHinta = Case R.Kirjaustapa WHEN 1 THEN verollinenkplHinta ELSE verotonkplHinta END, ');
adsTarjous.Sql.Add('R.Alennuspros, ISNULL(R.Alvpros,-1) AS Alvpros, R.rivisumma, R.Rivisaate, R.Rivityyppi, ');
adsTarjous.Sql.Add(' Eraseuranta = CASE R.Eraseuranta WHEN 0 THEN '+#39#39+' ELSE (SELECT NE.Selite FROM NimikeEra NE LEFT Join EraTapahtuma ET ON (NE.ID=ET.NimikeEraID) Where NE.Era=R.Era AND ET.RiviID=R.ID) END ');
adsTarjous.Sql.Add('From Tarjous T Left Outer Join TarjousRivi R ON (T.ID=R.ListaID) ');
adsTarjous.Sql.Add('Left Join Muistio M ON (T.MuistioID=M.ID) ');
adsTarjous.Sql.Add(' WHERE (ISNULL(R.Ohjaus,0) < 1104) AND T.ID = '+ IntToStr(Tarjous) );
end;
procedure frxReport1OnStartReport(Sender: TfrxComponent);
begin
Alusta;
end;
procedure MasterData1OnBeforePrint(Sender: TfrxComponent);
procedure LisaaMuksu;
begin
if MasterData1.Child = nil then
MasterData1.Child := Child1
else
Child1.Child := Child2;
end;
var
LokNum: Integer;
RiviID: String;
begin
LokNum := 0;
MasterData1.Child := nil;
Child1.Child := nil;
Child2.Child := nil;
if (<Tarjous."Rivisaate"> <> Null) OR (Length(<Tarjous."Eraseuranta">) > 0) then
begin
if Length(Trim(<Tarjous."Rivisaate">)) > 0 then
begin
Memo65.Style := 'Tahoma9Italic';
Set('Lokero'+IntToStr(LokNum),'''' + <Tarjous."Rivisaate"> + '''');
LisaaMuksu;
LokNum := LokNum + 1;
end;
if Length(<Tarjous."Eraseuranta">) > 0 then
begin
Set('Lokero'+IntToStr(LokNum), '''' + <Tarjous."Eraseuranta"> + '''');
LokNum := LokNum + 1;
LisaaMuksu;
end;
end;
end;
procedure Memo61OnBeforePrint(Sender: TfrxComponent);
begin
TfrxMemoView(Sender).Text := FormatFloat(Get('aHintaFormat')+';-'+Get('aHintaFormat')+';""',<Tarjous."aHinta">);
end;
procedure ReportSummary1OnBeforePrint(Sender: TfrxComponent);
begin
if Engine.FreeSpace < TfrxBand(Sender).Height then
begin
Engine.NewPage;
Engine.CurY := Engine.CurY + Engine.FreeSpace - TfrxBand(Sender).Height - 1;
end
else
Engine.CurY := Engine.CurY + Engine.FreeSpace - TfrxBand(Sender).Height - 1;
end;
procedure Memo48OnBeforePrint(Sender: TfrxComponent);
begin
Memo48.Text := Rivitetty(Get('Muistio'));
end;
Procedure MuistioPrint(Sender: TFrxComponent);
begin
if Length(Trim(Get('Muistio'))) = 0 then
TfrxHeader(Sender).Child := nil;
end;
procedure Memo59OnBeforePrint(Sender: TfrxComponent);
begin
if ((<Tarjous."Rivityyppi"> > 0) OR ((Trim(<Tarjous."Nimike">) = '')) AND (<Tarjous."Maara"> = 0)) then
TfrxMemoView(Sender).Text := '';
end;
begin
end.