请参见下面的代码,由于以下原因该代码返回运行时错误3265: strTo =!email_address1
但是,如果我将其更改为 strTo =!AccountNumber它将在Outlook电子邮件收件人中正确填充:行,但我需要电子邮件地址,而不是帐号-我需要定义email_address1吗?这是我的查询/报告中的短文本字段。如果是这样,我该如何定义?完全陌生。
Option Compare Database
Sub Mac1()
Dim rsAccountNumber As DAO.Recordset
Dim strTo As Variant
Dim strSubject As String
Dim strMessageText As String
Set rsAccountNumber = CurrentDb.OpenRecordset("SELECT DISTINCT AccountNumber, email_address1 FROM [P3_DVP_UnAffirmed_Report_for_En Query]", dbOpenSnapshot)
With rsAccountNumber
Do Until .EOF
DoCmd.OpenReport "Unaffirmed Report", _
acViewPreview, _
WhereCondition:="AccountNumber = '" & !AccountNumber & "'", _
WindowMode:=acHidden
strTo = !Email_Address1
strSubject = "Invoice Number "
strMessageText = "Text Here"
DoCmd.SendObject ObjectType:=acSendReport, _
ObjectName:="Unaffirmed Report", _
OutputFormat:=acFormatPDF, _
To:=strTo, _
Subject:=strSubject, _
MESSAGETEXT:=strMessageText, _
EditMessage:=True
DoCmd.Close acReport, "Unaffirmed Report", acSaveNo
.MoveNext
Loop
.Close
End With
End Sub
答案 0 :(得分:1)
在您的(\})(.*)({match})
列表中,应指定 email_address1 字段,以便:
SELECT