下面这段程序执行出错,提示could not convert variant of type (null) into type (double),我设置断点单步执行发现问题出在 "outsumvalues:=f_data.Outvaluescount.fieldbyname('出库总价').Value ; //出库总金额赋给变量"原因是f_data.Outvaluescount.fieldbyname('出库总价').Value 的数据集有时候返回结果是NULL,把NULL赋给REAL类性变量outsumvalues就出错了,请问高手我该如何改程序,谢谢了var outsumvalues,outsumquantity:real;   
....
with f_data.Outvaluescount do      
    begin
        close;
        sql.Clear ;
        sql.Add('select 出库总价=sum(account_values),出库总数=sum(出库数量) from 出库明细表');
        sql.Add('where [物料代码]=:partno and [库房]=:warehouse and [material_sort]=:msort');
        sql.Add('and Account_order_confirm=1');   
        parameters.ParamByName('partno').Value :=trim(stringgrid1.Cells[2,i]);
        parameters.ParamByName('warehouse').Value :=trim(stringgrid1.Cells[8,i]);
        parameters.ParamByName('msort').Value :=trim(stringgrid1.Cells[14,i]);
        open;
    end;
     if f_data.Outvaluescount.RecordCount>0 then
    begin
     outsumvalues:=f_data.Outvaluescount.fieldbyname('出库总价').Value ; //出库总金额赋给变量
     outsumquantity:=f_data.Outvaluescount.fieldbyname('出库总数').Value ; //出库总数量赋给变量
    end
    else
    begin
       outsumvalues:=0;
       outsumquantity:=0;
    end;