为什么我的Dlookup函数出现类型错误

时间:2019-01-30 19:03:58

标签: ms-access-2013

嗨,我在MS Access的表达式生成器中有一个dlookup

它涉及日期,当我运行它时,出现类型错误。

有什么想法吗?

=DLookUp("NewValue","[tblAuditTrail]","[frmName]='frmActionDetails' And ActionID='" & [Reports]![PATS_ACTIONID])

1 个答案:

答案 0 :(得分:0)

假设字段ActionID字符串值,那么您会丢失连接值前后的单引号:

=DLookUp
(
    "NewValue",
    "[tblAuditTrail]",
    "[frmName]='frmActionDetails' And ActionID='" & [Reports]![PATS_ACTIONID] & "'"
'                                                     You were missing this -----^
)

实际上,如果ActionID包含数字值(对于ID可能是这样),则不需要引号,例如:

=DLookUp
(
    "NewValue",
    "[tblAuditTrail]",
    "[frmName]='frmActionDetails' And ActionID=" & [Reports]![PATS_ACTIONID]
'          Removed single quote from here -----^
)