简体   繁体   English

DLookup 作为访问表单中的控制源的错误

[英]Errors in DLookup as a control source in access form

I have a text box with the control source of Dlookup function.我有一个带有Dlookup功能控件源的文本框。 But the Dlookup format makes me crazy, I tried a hundred times to refer another combo box value as criteria in Dlookup function.但是Dlookup格式让我发疯了,我尝试了一百次将另一个组合框值作为Dlookup函数中的标准。 I got either "# name?"我得到了“#名字?” or "# Error".或“# 错误”。

I tried this:我试过这个:

=DLookUp("[Contact]","Supllier","[Company]='" & [Forms]![PurchaseOrder]![cboSupplierCompany] & "'")

and got "# Error"并得到"# Error"

when I input :当我输入:

=DLookUp("[Contact]","Supllier","[Company]='" & [Me]![cboSupplierCompany] & "'")

I got "# Name?"我得到了"# Name?"

I finally found the solution.我终于找到了解决方案。 The right way to use Dlookup in a expression is to use the expression editor to select table field and form control.在表达式中使用 Dlookup 的正确方法是使用表达式编辑器选择表字段和表单控件。

the working expression of Dlookup in my textbox is : Dlookup 在我的文本框中的工作表达式是:

DLookUp(" [Supplier]![Contact] ","Supplier"," [Supplier]![Company] ='" & [cboSupplierCompany] & "'")

Using a SQL-query window above-like versions work fine.使用上面类似版本的 SQL 查询窗口工作正常。 But they did not work in the ControlSource property setting.但是它们在 ControlSource 属性设置中不起作用。

Here you have to use semicolons (;) instead of commas (,).这里必须使用分号 (;) 而不是逗号 (,)。 At least in a German language settings environment (?).至少在德语设置环境中(?)。 Control setting = in German:控制设置 = 德语:

Steuerelementinhalt
= DLookUp(" [Supplier]![Contact] ";"Supplier";"  [Supplier]![Company] ='" & [cboSupplierCompany] & "'"

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

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