|
本帖最后由 autocadr41 于 2015-6-14 11:43 编辑
你的部分代码(下面红色字体部分):
" ((select sum(iif(isnull(金额),0,金额)) from [期初余额$] where 编码=a.编码 and " & _
" 日期=#" & Sheets("测试2").[B2] - 1 & "# ) + (select sum(iif(isnull(金额),0,金额)) from [进仓明细$] where 编码=a.编码 and " & _
" 日期 between#" & Sheets("测试2").[B2] & "# and #" & Sheets("测试2").[C2] & "# ))/" & _
"((select sum(iif(isnull(数量),0,数量)) from [期初余额$] where 编码=a.编码 and " & _
" 日期=#" & Sheets("测试2").[B2] - 1 & "# )+(select sum(iif(isnull(数量),0,数量)) from [进仓明细$] where 编码=a.编码 and " & _
" 日期 between#" & Sheets("测试2").[B2] & "# and #" & Sheets("测试2").[C2] & "# )) as 单位成本" & _
" from ( select 编码 from [进仓明细$] union select 编码 from [出仓明细$] union select 编码 from [期初余额$] )a group by 编码"
用下面的代替试试:
iif(sum(金额) is null,0,sum(金额))
iif(sum(数量) is null,0,sum(数量)) |
|