【问题标题】:This expression is typed incorrectly, or it is too complex to be evaluated.此表达式键入不正确,或者它太复杂而无法计算。
【发布时间】:2018-03-12 09:40:11
【问题描述】:

此查询运行项目分类帐。当我尝试使用 =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];

【问题讨论】:

    标签: ms-access ms-access-reports


    【解决方案1】:

    在header中指定参数的数据类型

    PARAMETERS 
        [Forms]![Reports Window]![cmb_ar] Long,
        [Forms]![Reports Window]![ar_frm_dt] DateTime,
        [Forms]![Reports Window]![ar_to_dt] DateTime;
    SELECT 
        ITEM, [Transaction Date], ID, Reciept, Issued, Returns, Remarks, Manual
    FROM
    <snip>
    

    附录

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

    一种解决方案是让查询期望字段值是一个数字。这可以通过以下表达式来实现:

    IIf(False, 0, Null)
    

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

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

    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>
    

    【讨论】:

    • 尊敬的 Gustav,此报告在没有 =SUM([Returns]) 的情况下成功运行。在报告中应用 =SUM([Returns]) 会引发错误。
    • 您可能会成功使用=Sum(Val([Returns])) - 或查看编辑后的答案。
    • 谢谢古斯塔夫。使用 =SUM(Nz([Returns])) 解决。
    猜你喜欢
    • 2021-10-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-08
    • 1970-01-01
    • 2014-09-22
    相关资源
    最近更新 更多