我有两个访问子表单。 First Subform (Pivot1234Subform)
1)首先是(Pivot1234子窗体)。它采用pivot1234表格式。然后,此子窗体将在用户选择列表框和下拉文本框后显示数据。以下是生成此子表单的代码:
此子表单的目的是在单击“ pivot1234”报告中的摘要后,对FAMILY列和“ pivot1234_subform”中的whichTest中包含相同数据的数据总和进行计数。
示例
如果第一行:family = a,whichtest = b
然后第二行:family = a,whichtest = b
它将出现在第三列(计数)“ 2”中
下面是我已经在Form_Load事件中尝试过的代码:
{Private Sub Form_Load()
Dim strSQL As String
strSQL = "SELECT First(Pivot123_subform.Family) AS
[CountDuplicate_subform.Family], First(Pivot1234_subform.WhichTest) AS
[CountDuplicate_subform.WhichTest], Count(Pivot1234_subform.Family) AS
[CountDuplicate_subform.Count]" & _
"FROM Pivot1234_subform" & _
"GROUP BY Pivot1234_subform.Family, Pivot1234_subform.WhichTest" & _
"HAVING (((Count(Pivot1234_subform.Family))>1) AND
((Count(Pivot1234_subform.WhichTest))>1));"
Forms!CountDuplicate_subform.RecordSource = strSQL
Forms!CountDuplicate_subform.Form.Requery
End Sub