此表达式输入不正确,或者太复杂而无法进行评估。

时间:2018-03-12 09:40:11

标签: ms-access ms-access-reports

此查询运行项目分类帐。当我尝试使用= SUM([Returns])对访问报告上的返回字段求和时,即返回是访问报告上的文本框。它在运行报告时显示以下错误。 **

  

此表达式键入不正确,或者太复杂了   评估。例如,数字表达式可能包含太多   复杂的元素。尝试通过分配来简化表达式   部分表达式变量。

**

SELECT ITEM, [Transaction Date], ID, Reciept, Issued, Returns, Remarks, Manual
FROM 
 (SELECT t.item AS ITEM, irh.reciept_date AS [Transaction Date], ird.inv_id AS ID, ird.inv_qyt AS Reciept, Null AS Issued, NULL AS Returns, ird.remarks AS Remarks, ird.inv_manual_number AS Manual
FROM inventory_reciepts_header AS irh, inventory_reciepts_detail AS ird, inventory AS t
WHERE 
ird.inv_id=t.id 
AND ird.reciept_header_id=irh.id
UNION ALL

 SELECT t.item AS ITEM, iih.issue_date As  [Transaction Date], iid.inventory_id AS ID,NULL AS Reciept, iid.inventory_qyt AS Issued, NULL AS Returns, iid.remarks AS Remarks,Null AS Manual 
FROM inventory_issue_header AS iih, inventory_issue_detail AS iid,inventory 
AS t  WHERE  iid.inventory_id=t.id
    AND 
    iid.issue_header_id=iih.id

UNION ALL    
 SELECT t.item AS ITEM, iirh.return_date As  [Transaction Date], iir.item_id AS ID, Null AS Reciept, NULL AS Issued,iir.qyt AS Returns, iir.reasons AS Remarks,Null AS Manual 
FROM inventory_return_header AS iirh, inventory_return_detail AS iir, inventory AS t
WHERE      
iir.item_id=t.id
AND 
iir.return_header_id=iirh.id
 ) AS [ITEM Ledger]
WHERE ID=[Forms]![Reports Window]![cmb_ar]
and
[Transaction Date] between [Forms]![Reports Window]![ar_frm_dt] And [Forms]![Reports Window]![ar_to_dt];

1 个答案:

答案 0 :(得分:0)

在标题中指定参数的数据类型

IIf(False, 0, Null)

<强>附录

Sum 可能会失败,因为由于第一个查询中的 Null 值,该字段作为文本返回。

解决方案是使查询期望字段值为数字。这可以通过表达式来实现:

SELECT 
    t.item AS ITEM, 
    irh.reciept_date AS [Transaction Date], 
    ird.inv_id AS ID, 
    ird.inv_qyt AS Reciept, 
    IIf(False, 0, Null) AS Issued, 
    IIf(False, 0, Null) AS Returns, 
    ird.remarks AS Remarks, 
    ird.inv_manual_number AS Manual
FROM 
    inventory_reciepts_header AS irh, 
    inventory_reciepts_detail AS ird, 
    inventory AS t
<snip>

要检查的条件 False 将永远不会为True,因此表达式将始终返回Null,但是 - 尽管如此 - 查询将评估两个输出选项并将其确定为 numeric < / em>的。

插入表达式,查询将显示为:

<!DOCTYPE html>
<body>
  <div id="some_div">
      <textarea></textarea>
  </div>

  <div id="other_div"></div>
</body>