1

我有一个与名为“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
4

1 回答 1

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
于 2012-05-09T20:16:43.063 回答