我现在只做了一张fastReport报表,现在其它单元要调用。  怎么调用?能不能做成一个函数,供其它单元调用,放在Public.Pas里边请列下具体代码,谢谢。

解决方案 »

  1.   

    保存成文件,动态调入
    frxReport1.LoadFromFile('D:\1.fr3');
    frxReport1.ShowReport();
      

  2.   

    在窗体上必须放fastreport的相关组件,报表组件和数据源组件,并处理好数据连接。再按1楼的方法就可以了。
      

  3.   


    好的,我试试!    能不能直接在一个类里边声明一下,类里边包括fastreport的相关组件,但是不创建窗体行吗?
      

  4.   

    有点小问题,第一次点击的时候没有出错,第二次点击的时候会报错。---------------------------
    Debugger Exception Notification
    ---------------------------
    Project Rsa.exe raised exception class EAccessViolation with message 'Access violation at address 00000000. Read of address 00000000'. Process stopped. Use Step or Run to continue.
    ---------------------------
    OK   Help   
    ---------------------------
    procedure TFrm_AppSearch.BtnRefreshClick(Sender: TObject);
    var
      Str_SQL:String;
      Str_Path,Str_RPFile:string;begin
      inherited;
          try
                try
                      Str_SQL := ' select  periodName,dlTo.DeptName DeptName,dlFrom.DeptName FromDeptName,convert( varchar(100), AppointTime, 23)AppointTime,   ';
                      Str_SQL := Str_SQL + '  dbo.f_realName(app.ManCreate) ManCreate, app.* ';
                      Str_SQL := Str_SQL + '  from appointList app  ';
                      Str_SQL := Str_SQL + '  left join periodList per  ';
                      Str_SQL := Str_SQL + '  on app.periodID=per.periodID  ';
                      Str_SQL := Str_SQL + '  left join DeptList dlTo  ';
                      Str_SQL := Str_SQL + '  on app.DeptID=dlTo.ID  ';
                      Str_SQL := Str_SQL + '  left join DeptList dlFrom  ';
                      Str_SQL := Str_SQL + '  on app.FromDeptID=dlFrom.ID  ';
                      Str_SQL := Str_SQL + ' where SNO=:SNO';                  Query_RP.Close;
                      Query_RP.SQL.Clear;                                         //打印报表
                      Query_RP.SQL.Add(Str_SQL);
                      Query_RP.Parameters.ParamByName('SNO').Value := Query_Search.FieldByName('SNO').AsString;
                      Query_RP.Open;                  Str_Path:=  ExtractFilePath( Application.ExeName );
                      Str_RPFile := Str_Path + 'RP\rp3.fr3';
                      frxReport1.LoadFromFile(Str_RPFile);
                      frxReport1.PrepareReport();
                      frxReport1.PrintOptions.ShowDialog:=false;
                      frxReport1.print;
                except
                      on E:Exception do
                      begin
                            Write_LogErr(FinalUnit+'0001:重新打印处',IntToStr(E.HelpContext)+':'+E.Message,'');
                      end;
                end;//end except      finally
                Query_RP.Close;
          end;//end finally
    end;
      

  5.   


    frxReport1.LoadFromFile(Str_RPFile);
    是不是这句话只能写一次,试试
      

  6.   

    frxReport1.PrepareReport();是在这个地方报错