[英]DLookup with Multiple Criteria
I have an Access DB that has the following tables: 我有一个具有下表的Access DB:
• 'Legal Entity Info' with [LegEntID] and [LegEntName] •具有[LegEntID]和[LegEntName]的“法律实体信息”
• 'Policy Info' with [PolicyID] and [PolicyCarrierName] •具有[PolicyID]和[PolicyCarrierName]的“政策信息”
• 'Policy Period' with [PolicyPeriodID] and [PolicyPeriod] •具有[PolicyPeriodID]和[PolicyPeriod]的“政策期限”
• 'Retention Amounts by Legal Entity' with [RetentionID], [PolicyPeriodID], [PolicyID], [LegEntID] and [RetentionAmount] •具有[RetentionID],[PolicyPeriodID],[PolicyID],[LegEntID]和[RetentionAmount]的“按法人划分的保留金额”
I have a form (Retention Payment Info Form), that pulls in the [PolicyPeriodID], [PolicyID], and [LegEntID] that are connected with a specific claim. 我有一个表格(保留付款信息表格),其中提取了与特定声明有关的[PolicyPeriodID],[PolicyID]和[LegEntID]。 I need to pull in the correct [RetentionAmount] that corresponds to the match in the 'Retention Amounts by Legal Entity' table. 我需要提取与“按法律实体划分的保留金额”表中的匹配项对应的正确[RetentionAmount]。 All three criteria ([PolicyPeriodID], [PolicyID], and [LegEntID]) have to be TRUE in order to pull in the correct [RetentionAmount]. 为了引入正确的[RetentionAmount],所有三个条件([PolicyPeriodID],[PolicyID]和[LegEntID])必须为TRUE。
On this form, I have an unbound field to show the [RetentionAmount] and I'm trying to write a DLookup function to select the [RetentionAmount] based on the selections on the form. 在此表单上,我有一个未绑定的字段来显示[RetentionAmount],并且我正在尝试编写DLookup函数以根据表单上的选择来选择[RetentionAmount]。 Here is what I think it should look like, however, it's not working. 我认为这应该是这样,但是它不起作用。
=DLookUp("[RetentionAmount]",
"Retention Amounts by Legal Entity",
"[PolicyPeriodID]='" & Forms![Retention Payment Info Form].Form.[PolicyPeriodID] &
"' AND [PolicyID]='" & Forms![Retention Payment Info Form].Form.[PolicyID] &
"' AND [LegEntID]='" & Forms![Retention Payment Info Form].Form.[LegEntID] &
"'")
Any suggestions? 有什么建议么?
.Form
is only needed when working with subforms. .Form
仅在使用子.Form
时才需要。
http://access.mvps.org/access/forms/frm0031.htm is a good reference. http://access.mvps.org/access/forms/frm0031.htm是一个很好的参考。
(You are here: Forms!Mainform!ControlName
) (您在这里: Forms!Mainform!ControlName
)
Correct syntax: 正确的语法:
=DLookUp("[RetentionAmount]",
"Retention Amounts by Legal Entity",
"[PolicyPeriodID]=" & Forms![Retention Payment Info Form]![PolicyPeriodID] &
" AND [PolicyID]=" & Forms![Retention Payment Info Form]![PolicyID] &
" AND [LegEntID]=" & Forms![Retention Payment Info Form]![LegEntID])
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.