access中如何使用dlookup函数自动填充文本框

how to auto-fill text box with the dlookup function in access

我正在尝试使用 Dlookup 函数自动填充文本框,如下所示:

=DLookUp("[CustomerFACT]![ID name]","CustomerFACT","[CustomerFACT]![ID number] = " & [Forms]![NewLoanForm_2]![ID number])
  1. 我原来的列名之间有空格
  2. 代码似乎有效,只是在我输入 ID 后,它用 #Error
  3. 填充文本框

提前致谢

试试这个更简单的语法:

=DLookUp("[ID name]","[CustomerFACT]","[ID number] = " & [ID number] & "")

或者,如果 ID number 是文本:

=DLookUp("[ID name]","[CustomerFACT]","[ID number] = '" & [ID number] & "'")