1

访问 2007

Form Name is: MineLocationQuery1
1st Subform name is:MineExtractionSubform
2nd Subform name is: ExtractionLineSubform2

我正在尝试使用 dlookup 来检查表中的值,然后将其乘以另一个值。它适用于:NO Subform 和 1 Subform。但是当我添加 2 个子表单时,我无法让它工作。

这是我到目前为止尝试过的

有效的简单表单查找:

=DLookUp("[Price]","[Resource]","[AtomicRef]='" & [Forms]![ExtractionLine]![AtomicRef] & "'")*[Tonnage]

这是使用 1 个子表单创建的表单的工作示例:

=DLookUp("[Price]","[Resource]","[AtomicRef]='" & [Forms]![MineExtraction1]![ExtractionLineSubform]![AtomicRef] & "'")*[Tonnage]

这是我对 2 个子表单进行的许多尝试中的 1 个,但它不起作用。

=DLookUp("[Price]","[Resource]","[AtomicRef]='" & Forms![MineLocationQuery1]!MineExtractionSubform.Form!ExtractionLineSubform2.Form.AtomicRef & "'")*[Tonnage]

除了在将许多尝试复制并粘贴到价值文本框控件源中并反复出现#Name错误之外,我做错了什么

4

1 回答 1

1

如果我想在主表单的文本框中引用嵌套子表单,我可能会说:

=[SubformControl1].[Form].[SubformControl2].[Form].[AControlName]

Note that this uses the name of the subform control and Form as a reference to the object contained by the control.

So this (split for ease of reading) looks right:

=DLookUp("[Price]","[Resource]","[AtomicRef]='" & Forms![MineLocationQuery1]!
MineExtractionSubform.Form!ExtractionLineSubform2.
Form.AtomicRef & "'")*[Tonnage]

However, it is very easy to get names wrong. For example, you may be referring to the form contained, rather than the subform control name. You can use the Expression Builder to troubleshoot, or you can refer to the form bit by bit in the immediate window (Ctrl+G) to ensure you have the names right. For example:

?Forms![MineLocationQuery1].Name
?Forms![MineLocationQuery1]!MineExtractionSubform.Name

More information: http://access.mvps.org/access/forms/frm0031.htm

EDIT re comments

If you work in subform 2, as I believe you should in this case, you can simply refer to [atomicref]:

=DLookUp("[Price]","[Resource]","[AtomicRef]='" & [atomicref] & "'")
于 2012-11-21T14:52:38.147 回答