在 MS Access 2010 数据库中,我有一个导航子表单,其中包含一些文本框,其值是从基础查询中填充的,以及一个计算的文本框。我想在计算的文本框中添加一些条件逻辑。
其中两个填充的文本框是 ClientNumber 和 DOB。在表达式生成器中,计算的文本框是 Age,当前计算如下:
=DateDiff("yyyy",[DOB],Now())+Int(Format(Now(),"mmdd")<Format([DOB],"mmdd"))
我想将年龄计算更改为类似于以下伪代码:
=IiF(
ClientNumber IN qryActiveClients,
DateDiff("yyyy",[DOB],Now())+Int(Format(Now(),"mmdd")<Format([DOB],"mmdd")) ,
"NA"
)
有人可以告诉我如何更改此伪代码,使其成为完成所需任务的实际工作代码吗?
作为参考,qryActiveClients 如下:
SELECT DISTINCT
ActiveCustomers.FirstName,
ActiveCustomers.LastName,
tblClientAddress.HomePhone,
ActiveCustomers.ClientNumber
FROM
(
SELECT
Clients.ClientNumber,
Clients.FirstName,
Clients.LastName,
(
SELECT COUNT(ReferralDate) FROM IntakeTable
WHERE Clients.ClientNumber = IntakeTable.ClientNumber
AND Len(ReferralDate & '') > 0
) AS IntakeCount,
(
SELECT COUNT(ExitDate) FROM ExitTable
WHERE Clients.ClientNumber = ExitTable.ClientNumber
AND Len(ExitDate & '') > 0
) AS ExitCount FROM Clients
) AS ActiveCustomers
INNER JOIN tblClientAddress
ON ActiveCustomers.ClientNumber = tblClientAddress.ClientNumber
WHERE (((ActiveCustomers.IntakeCount)>[ExitCount]) AND ((tblClientAddress.CurrentResidence)=True));
请注意,qryActiveClients 与填充其他控件的查询不同。