简体   繁体   English

Access 中的 DLookup 函数返回类型不匹配错误

[英]DLookup Function in Access returns Type Mismatch Error

I'm trying to use the DLookup function and it keeps giving me a type mismatch error.我正在尝试使用 DLookup 函数,但它一直给我一个类型不匹配错误。 See code below:见下面的代码:

If IsNull(DLookup("[CheckedOutTo]", "tbl_Transaction", "[CheckedInDate]" = Null And "AssetID = " & Forms!frm_NewTransaction!SN))

CheckedOutTo is Short Text, CheckedInDate is a date, and AssetID is a number. CheckedOutTo 是短文本,CheckedInDate 是日期,而 AssetID 是数字。 I'm not sure what I'm doing wrong or if there's an error in my syntax somewhere.我不确定我做错了什么,或者我的语法是否有错误。 Thanks in advance for the help.在此先感谢您的帮助。

您需要将标准值作为提供给DLookup的字符串的一部分包括在内,即:

If IsNull(DLookup("CheckedOutTo", "tbl_Transaction", "CheckedInDate is null and AssetID = Forms!frm_NewTransaction!SN"))

我认为你需要这样做:

If IsNull(DLookup("CheckedOutTo", "tbl_Transaction", "CheckedInDate is Null and AssetID = " & Forms!frm_NewTransaction!SN)) Then ...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM