用delphi做 報表時,出現如下錯誤,請問是什麼原因引起的,怎麼解決
Project Pro_CGGL.exe raised exception class EOleException with message 'An unknown error has occurred'. Process stopped. Use Step or Run to continue.

解决方案 »

  1.   

    var
      sqlStr:String;
    begin
        sqlStr:='SELECT * FROM  wdb_ant WHERE 1=1  ';
        if Trim(edDate1.Text)<>'' then
          sqlStr:=sqlStr+' AND date>=' +''''+trim(edDate1.Text)+'''';
        if Trim(edDate2.Text)<>'' then
          sqlStr:=sqlStr+' AND date<=' +''''+trim(edDate2.Text)+'''';    if Trim(edNo1.Text)<>'' then
          sqlStr:=sqlStr+' AND orno>=' +''''+trim(EdNo1.Text)+'''';
        if Trim(edNo2.Text)<>'' then
          sqlStr:=sqlStr+' AND orno<=' +''''+trim(EdNo2.Text)+'''';    if Trim(edCli1.Text)<>'' then
          SqlStr:=sqlStr+' AND CLI>='+''''+trim(edcli1.Text)+'''';
        if Trim(edCli2.Text)<>'' then
          SqlStr:=sqlStr+' AND CLI<='+''''+trim(edcli2.Text)+'''';    if Trim(edSeries1.Text)<>'' then
          SqlStr:=sqlStr+' AND series>='+''''+trim(edSeries1.Text)+'''';
        if Trim(edSeries2.Text)<>'' then
          SqlStr:=sqlStr+' AND series<='+''''+trim(edSeries2.Text)+'''';    if Trim(edPcode1.Text)<>'' then
          SqlStr:=sqlStr+' AND code>='+''''+trim(edPcode1.Text)+'''';
        if Trim(edPcode2.Text)<>'' then
          SqlStr:=sqlStr+' AND code<='+''''+trim(edPcode2.Text)+'''';
        QryQrp.Close;
        QryQrp.SQL.Clear;
        QryQrp.SQL.Text:=sqlStr+' ORDER BY cli,code,date DESC';
        QryQrp.Open;    if QryQrp.RecordCount=0 then
        begin
          ShowWarning('找不到記錄,沒資料可列印!');
          exit;
        end;    if (trim(eddate1.Text)<>'') or (trim(eddate2.Text)<>'') then
        begin
           labDate1.Caption:=Trim(eddate1.Text);
           labdate2.Caption:=Trim(eddate2.Text);
        end
        else
        begin
           labdatefrom.Caption:='';
           labdate1.Caption:='';
           labdate2.Caption:='';
           labdatefrom.Caption:='';
           labdate1.Visible:=False;
           labdate2.Visible:=False;
           labdateTo.Visible:=False;
        end;
        if (trim(edseries1.Text)<>'') or (trim(edseries2.Text)<>'') then
        begin
           labseries1.Caption:=Trim(edseries1.Text);
           labseries2.Caption:=Trim(edseries2.Text);
        end
        else
        begin
           labfromseries.Caption:='所有系列';
           labseries1.Caption:='';
           labseries2.Caption:='';
           labseriesto.Caption:='';
           labseries1.Visible:=False;
           labseries2.Visible:=False;
           labSeriesTo.Visible:=False;
        end;    if (Trim(edPcode1.Text)<>'') or (trim(edPcode2.Text)<>'') then
        begin
          labPcode1.Caption:=Trim(edPcode1.Text);
          labPcode2.Caption:=Trim(edPcode2.Text);
        end
        else
        begin
          labPcodefrom.Caption:='所有物料';
          labpcode1.Caption:='';
          labpcodeTo.Caption:='';
          labpcode2.Caption:='';
          labpcode1.Visible:=False;
          labpcodeTo.Visible:=False;
          labpcode2.Visible:=False;
        end;    if (Trim(edno1.Text)<>'') or (trim(edno2.Text)<>'') then
        begin
          labOrno1.Caption:=Trim(edno1.Text);
          labOrno2.Caption:=Trim(edno2.Text);
        end
        else
        begin
          labOrnofrom.Caption:='所有采購合約';
          labOrno1.Caption:='';
          labOrnoTo.Caption:='';
          labOrno2.Caption:='';
          labOrno1.Visible:=False;
          labOrnoTo.Visible:=False;
          labOrno2.Visible:=False;
        end;    if (Trim(edcli1.Text)<>'') or (trim(edcli2.Text)<>'') then
        begin
          labCli1.Caption:=Trim(edCli1.Text);
          labCli2.Caption:=Trim(edCli2.Text);
        end
        else
        begin
          labClifrom.Caption:='所有供應商';
          labCli1.Caption:='';
          labCliTo.Caption:='';
          labCli2.Caption:='';
          labCli1.Visible:=False;
          labCliTo.Visible:=False;
          labCli2.Visible:=False;
        end;
        Qrlabtime.Caption:=timeToStr(Time);
        labprintdate.Caption:=DateToStr(now);    QuickRep2.PreviewModal;end;以上我都單步執行過了,以上代碼沒問題,就在預覽報表時出錯了啦!
      

  2.   

    問題找到了,我在ADOQuery中用了lookup字段所引起的,多謝大家的關照!