[txt_AmendmentOF]],用于计算特定记录在数据库中具有的修订总数。因此用户知道他们正在进行的修订。很简单,您正在进行第3项修订3,我在文本框[txt_AmendmentOF]:
的“控制源”字段中使用此计算。=IIf(IsNull([txt_Amendment]),0,Count([MIPR_Number]))
我的表上有一个名为的字段,其在表单上的文本框称为[txt_Amendment]。如果[txt_AmendmentOF]为空,我将在[txt_AmendmentOF]中返回零。我需要它来计数相同的记录编号[MIPR_Number],并在[txt_AmendmentOF]文本框中返回修订计数的总数。在我的桌子上,我有一个称为[ID]的私钥字段,它是一种自动编号格式。上面代码的问题是,对所有具有[MIPR_Number]的字段进行计数,并返回该字段的总行数。我不是这里的专家,所以我们将不胜感激。更新为发布。我也尝试过此操作,并在文本框中出现错误[Amendment]
=IIf(IsNull([txt_Amendment]),0,Count([MIPR_Number]=[txt_MIPR_Number]))
要计数相同[MIPR_Number]
,您必须将数据分组(一组包含相同的数字),然后计数。
SELECT COUNT(id) as CountOfSameNr, [MIPR_Number] FROM Table GROUP BY [MIPR_Number]
将该查询存储为例如CountMIPRNumber。现在您有两个选择:
使用Dlookup获取一个值
=IIf(IsNull([txt_Amendment]),0,Dlookup("CountOfSameNr","CountMIPRNumber","[MIPR_Number] = " & [MIPR_Number]))
或将查询添加到表单记录源(在[MIPR_Number]上联接,“ SELECT * FROM TABLE”是表单查询)
SELECT CountMIPRNumber.CountOfSameNr, TABLE.* FROM TABLE LEFT JOIN CountMIPRNumber ON TABLE.[MIPR_Number] = CountMIPRNumber.[MIPR_Number]
并引用计数字段
=IIf(IsNull([txt_Amendment]),0,[CountOfSameNr])