Trying to generate an email from email addresses pulled from a query. I have parts of this code working in other areas But his one never makes it past the
line:
Set rs = db.OpenRecordset("qry_EmailAddresses")
No errors, no nothing. I have put message boxes in to see where the code stops, so I know it stops at that line. The query exists and is spelled correctly.
I have seen many example that use these lines of code, why is mine failing?
Thanks in advance...
Here's the full code......
Private Sub Command331_Click()
Dim stmailList As String
Dim db As Database
Dim rs As Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("qry_EmailAddresses")
stmailList = ""
rs.MoveFirst
Do
stmailList = stmailList & rs.Fields("EmailAdx")
rs.MoveNext
Loop Until rs.EOF
rs.Close
Set rs = Nothing
Set db = Nothing
Dim ol As Outlook.Application
Dim NewMessage As Outlook.MailItem
Dim stmailList As String
Set ol = New Outlook.Application
Set NewMessage = ol.CreateItem(olMailItem)
NewMessage.Subject = stmailList
NewMessage.To = stmailList
NewMessage.Display
End Sub
line:
Set rs = db.OpenRecordset("qry_EmailAddresses")
No errors, no nothing. I have put message boxes in to see where the code stops, so I know it stops at that line. The query exists and is spelled correctly.
I have seen many example that use these lines of code, why is mine failing?
Thanks in advance...
Here's the full code......
Private Sub Command331_Click()
Dim stmailList As String
Dim db As Database
Dim rs As Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("qry_EmailAddresses")
stmailList = ""
rs.MoveFirst
Do
stmailList = stmailList & rs.Fields("EmailAdx")
rs.MoveNext
Loop Until rs.EOF
rs.Close
Set rs = Nothing
Set db = Nothing
Dim ol As Outlook.Application
Dim NewMessage As Outlook.MailItem
Dim stmailList As String
Set ol = New Outlook.Application
Set NewMessage = ol.CreateItem(olMailItem)
NewMessage.Subject = stmailList
NewMessage.To = stmailList
NewMessage.Display
End Sub