【发布时间】:2016-09-28 17:28:27
【问题描述】:
我正在尝试从一个访问表中读取发送一封电子邮件“Email1”,然后将日期写入相应的记录“Email2”。要查找相应的记录,两个表中的字段 RecID 将匹配。我不断返回“语法错误”在“rs1.Edit where rs!MaxOfForm_Record_Number = rs1.MaxOfForm_Record_Number”下方突出显示这一行的错误
Function EmailTest1()
Dim rs As Recordset
Dim strBody As String
Dim strBody2 As String
Dim strRecipient As String
Dim rs1 As Recordset
Set rs1 = CurrentDb.OpenRecordset("Email2")
Set rs = CurrentDb.OpenRecordset("Email1")
Dim strName As String
Dim strProject As String
Dim strLastDate As String
Dim strNow As String
Dim emailcheck As String
rs.MoveLast
rs.MoveFirst
For i = 1 To rs.RecordCount
If IsNull(rs!EmailStat) = True Then
strNow = Now()
strName = rs!Inspected_By
strProject = rs!Site_Location
strLastDate = rs!LastOfDate_Time_of_Inspection
strBody2 = "BLah blah text "
rs1.Edit where rs!RecID = rs1.RecID
rs1![EmailStat].Value = strNow
rs1.Update
strBody = "blahblah"
strRecipient = rs!Email
DoCmd.SendObject , , , strRecipient, , , "Subject", strBody, False, False
End If
rs.MoveNext
Next i
Set rs = Nothing
End Function
【问题讨论】: