我想提取Member.HomeEmail
并将其存储在strEmail
中,如果找到更多邮件地址,则使用;
将它们分开
1@mail.com; 2@mail.com; 3@mail.com
,以便我可以将Outlook中的结果用作strBCC = strEmail
Private Sub Command610_Click()
Dim strEmail
SELECT Member.HomeEmail
FROM Member INNER JOIN MemberRole ON Member.MemberID = MemberRole.MemberID
WHERE (((MemberRole.RoleID)=1) AND ((Member.ConstituencyPrefix)="DF") AND ((MemberRole.FinishDate) Is Null))
ORDER BY Member.Surname;
End Sub
欢迎提供帮助。我真的不知道如何在VBA中运行查询;我试过DoCmd.RunSQL strSQL
,但这不是正确的行动。
我快到了:
变量strCons包含一个数字,我想在执行此操作时将其添加到SQL中,如下所示,我得到运行时错误'3061'参数太少。 Expexted 1.试图找出没有运气的原因。
Dim rs As DAO.Recordset Dim strEmailTD As String
设置rs = CurrentDb.OpenRecordset(“SELECT Member.HomeEmail FROM Member INNER JOIN MemberRole ON Member.MemberID = MemberRole.MemberID WHERE(((MemberRole.AreaID)= strCons) AND((MemberRole) .RoleID)= 1)AND((MemberRole.FinishDate)为空))ORDER BY Member.Surname“)strEmailTD = rs.Fields(0).Value rs.Close
答案 0 :(得分:0)
将 SQL 分配给变量,并在打开记录集时使用它:
Dim rs As DAO.Recordset
Dim HomeEmail As String
Set rs = CurrentDb.OpenRecordset(SQL) ' Your SQL.
HomeEmail = rs.Fields(0).Value
rs.Close