请试:
Dlookup 查询不到时,传回null,
Dim intNum as intger
intNum=IIf(isNull(Dlookup(...),0,Dlookup(...))
if((dlookup("[庫存]","庫存","[料號]='" & FORMs!領料主檔.領料總計!料號 & "' and [批號]='" & FORMs!領料主檔.領料總計!批號 & "'")< FORMs!領料主檔.領料總計!領料數量 then
msgbox"您的領料有誤,請更正",,"aa"
end if