BennyLinton
Registered User.
- Local time
- Yesterday, 22:25
- Joined
- Feb 21, 2014
- Messages
- 263
I'm having a problem with this block of code in a sub, no errors, just not updating my table (complete code included). Thanks!!!:
Code:
uq = "UPDATE Applicants set Applicants.Emailed = -1 WHERE Applicants.[GCDF No] = rs.[GCDF No]"
DoCmd.OpenQuery uq
Code:
Private Sub btnEmail_Click()
Dim rs As Recordset
Dim uq As String
Dim oApp As Object
Set oApp = GetObject(, "Outlook.Application")
If Err <> 0 Then
Set oApp = CreateObject("Outlook.Application")
Started = True
End If
On Error Resume Next
Set rs = CurrentDb.OpenRecordset("qryContactsEmail", dbReadOnly)
If Not (rs.EOF And rs.BOF) Then
rs.MoveFirst
Do Until rs.EOF = True
Set oItem = oApp.CreateItem(olMailItem)
With oItem
.From = "GCDF"
.To = rs!fldEmailAddress
.Subject = "Test"
.Body = "This is a system-generated e-mail, please do not reply"
.Send
uq = "UPDATE Applicants set Applicants.Emailed = -1 WHERE Applicants.[GCDF No] = rs.[GCDF No]"
DoCmd.OpenQuery uq
End With
rs.MoveNext
Loop
Else
MsgBox "There are no records in the recordset."
End If
rs.Close
Set rs = Nothing
Set oItem = Nothing
If Started Then
oApp.Quit
End If
End Sub