I'm baaaack! I've searched for a while but could find no answers. Could you help me?
I have table that contains, among other things, an email address and a date field for the day that I emailed them.
I have built the following vba code to loop through a query (built off the table, containing the email and date fields mentioned above) to send an email. Works perfectly. What I want to do is set the [First Contact Date] to today's date for each record.
Here's the code:
I'm trying to use the loop I already created to do the date for each record, so I put in that line
Problem: It only updates the very last record to today's date.
What am I missing? I'm sorry if I did not supply enough information, or if this question has been answered elsewhere. If so, could you please point me in the right direction?
Many thanks!
Melody
I have table that contains, among other things, an email address and a date field for the day that I emailed them.
I have built the following vba code to loop through a query (built off the table, containing the email and date fields mentioned above) to send an email. Works perfectly. What I want to do is set the [First Contact Date] to today's date for each record.
Here's the code:
Code:
Private Sub Command23_Click() Dim strEMail As String Dim oOutlook As Object Dim oMail As Object Dim strAddr As String Dim strBody As String Dim MyDB As DAO.Database Dim rstEMail As DAO.Recordset Set oOutlook = CreateObject("Outlook.Application") Set oMail = oOutlook.CreateItem(0) 'Retrieve all E-Mail Addressess in qryCurrent1stContact Set MyDB = CurrentDb Set rstEMail = MyDB.OpenRecordset("Select * From [qryCurrent1stContact]", dbOpenSnapshot, dbOpenForwardOnly) With rstEMail Do While Not .EOF 'Build the Recipients String strEMail = strEMail & ![E-mail] & ";" [First Contact date] = Now() 'this is the line of interest .MoveNext Loop End With '-------------------------------------------------- 'Set what will be in the body of the email strBody = DLookup("EmailBody", "tblEmailBodies", "[ID] = 1") With oMail .To = "email@email.fake" .Bcc = Left$(strEMail, Len(strEMail) - 1) 'Remove Trailing ; .Body = strBody .Importance = 2 .Subject = "Important Information From us - Please Read!" .Display End With Set oMail = Nothing Set oOutlook = Nothing rstEMail.Close Set rstEMail = Nothing End Sub
Code:
[First Contact date] = Now()
What am I missing? I'm sorry if I did not supply enough information, or if this question has been answered elsewhere. If so, could you please point me in the right direction?
Many thanks!
Melody
Comment