我试图找到"部门"来自表格" tblLenderAddress",其中"贷方"等于ComboBox" cmbLender"中的选定值。
出于调试目的,这很好用:
=DLookUp("[Department]","[tblLenderAddress]","Lender = 'Barclays'")
然而,这些不是:
=DLookUp("[Department]","[tblLenderAddress]","Lender = " & [Forms]![frmDetails]![cmbLender])
=DLookUp("[Department]","[tblLenderAddress]","Lender = " & [Forms]![frmDetails]![cmbLender].[Value])
=DLookUp("[Department]","[tblLenderAddress]","Lender = " & [Forms]![frmDetails]![cmbLender.value])
=DLookUp("[Department]","[tblLenderAddress]","Lender = " & [Me]![cmbLender])
我确定这是一个简单的解决方法,但谷歌在我试过的每个查询变体的前两页都让我失望。
答案 0 :(得分:2)
工作DLookup
示例中的第三个参数包括 Barclays 之前和之后的引号。
"Lender = 'Barclays'"
因此,当您根据组合框的当前值动态创建参数时,请包含这些引号...
"Lender = '" & Me!cmbLender.Value & "'"
答案 1 :(得分:1)
为了澄清,修复是;
= DLookUp(“[Department]”,“[tblLenderAddress]”,“Lender ='”& [表格]![frmDetails]![cmbLender]。[正文]& “'”)