vba “#Name?” 使用 DLookup 访问时出错
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16360086/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
" #Name? " error in access using DLookup
提问by Bawn
What I am trying to do is to have a value("Element" which is a primary key) from my Elements table be inserted into the time textbox based on the result from the previous combox.
我想要做的是根据前一个 combox 的结果将 Elements 表中的值(“Element”,它是主键)插入到时间文本框中。
Is this the write snytax to achieve this ??
这是为了实现这一点而写的 snytax 吗?
=DLookUp("[Time]","[Elements]","[Element]=" & [Forms]![1 Cut Wire and Cable Only]![Element])
回答by Gord Thompson
I suspect that there is a mismatch between the name of your combo box control and name you use in your DLookup. Try changing the combo box control's Name to cbxElement
and then using
我怀疑您的组合框控件的名称与您在 DLookup 中使用的名称不匹配。尝试将组合框控件的名称更改为cbxElement
,然后使用
=DLookUp("[Time]","[Elements]","[Element]=""" & [cbxElement] & """")
for the Control Source of the text box. Note that it is usually a good idea to use a prefix like "cbx" for combo boxes, "txt" for text boxes, etc., because
为文本框的控件源。请注意,对组合框使用“cbx”等前缀,对文本框使用“txt”等前缀通常是个好主意,因为
it makes them easier to find in an IntelliSense list, and
it avoids potential conflicts when the name of a controlis identical to the name of a fieldin the underlying record source.
它使它们更容易在 IntelliSense 列表中找到,并且
当控件名称与基础记录源中的字段名称相同时,它可以避免潜在的冲突。