我有一个命令按钮绑定到名为“GenderCount”的查询。单击按钮时,结果显示在子表中。我需要将结果显示在表单的文本框中(Text26)。这是我的代码 - 提前感谢任何建议:
Private Sub Command21_Click()
On Error GoTo Err_Command21_Click
Dim stDocName As String
stDocName = "GenderCount"
DoCmd.OpenQuery stDocName, acNormal, acEdit
Exit_Command21_Click:
Exit Sub
Err_Command21_Click:
MsgBox Err.Description
Resume Exit_Command21_Click
End Sub
答案 0 :(得分:0)
这就是你需要的
Private Sub Command21_Click()
On Error GoTo Err_Command21_Click
me.txtField1 = dlookup("CountOfGender","GenderCount","Gender = M")
me.txtField1 = dlookup("CountOfGender","GenderCount","Gender = F")
Exit_Command21_Click:
Exit Sub
Err_Command21_Click:
MsgBox Err.Description
Resume Exit_Command21_Click
End Sub