Hi all, still very much a newbie here and i'm trying to learn as i go.
Here's my issue, i'm trying to create an email with list of numbers in the email body which come from field strEquipNum in temp table ttblIxReview
To begin with i was doing this from a continuous form. I could get the email to open with data in the body but the same data was being repeated and wasn't looping through the table. I figured out that was because of the form. So i tried putting a button on a single form and using the temp table as a recordset and now i can't get it to find the table. To my untrained newbie eye it looks like it should work but obviously it isn't and i can't see/ have no idea what it is i'm not doing right.
Thank you for looking, any pointers would be greatly appreciated.
Code below-
Private Sub Command29_Click()
Dim MyOutlook As Outlook.Application
Dim MyMail As Outlook.MailItem
Dim db As DAO.Database
Dim rst As DAO.Recordset
Set MyOutlook = New Outlook.Application
Set db = CurrentDb()
Set rst = db.OpenRecordset("ttblIxReview")
Set MyMail = MyOutlook.CreateItem(olMailItem)
Do Until rst.EOF
MyMail.Body = [strEquipNum]
rst.MoveNext
Loop
MyMail.Display
Set MyOutlook = Nothing
Set rst = Nothing
Set db = Nothing
End Sub
Here's my issue, i'm trying to create an email with list of numbers in the email body which come from field strEquipNum in temp table ttblIxReview
To begin with i was doing this from a continuous form. I could get the email to open with data in the body but the same data was being repeated and wasn't looping through the table. I figured out that was because of the form. So i tried putting a button on a single form and using the temp table as a recordset and now i can't get it to find the table. To my untrained newbie eye it looks like it should work but obviously it isn't and i can't see/ have no idea what it is i'm not doing right.
Thank you for looking, any pointers would be greatly appreciated.
Code below-
Private Sub Command29_Click()
Dim MyOutlook As Outlook.Application
Dim MyMail As Outlook.MailItem
Dim db As DAO.Database
Dim rst As DAO.Recordset
Set MyOutlook = New Outlook.Application
Set db = CurrentDb()
Set rst = db.OpenRecordset("ttblIxReview")
Set MyMail = MyOutlook.CreateItem(olMailItem)
Do Until rst.EOF
MyMail.Body = [strEquipNum]
rst.MoveNext
Loop
MyMail.Display
Set MyOutlook = Nothing
Set rst = Nothing
Set db = Nothing
End Sub