Sunny Boy 1318
Registered User.
- Local time
- Today, 08:09
- Joined
- May 9, 2013
- Messages
- 40
Hi Everyone,
To make it simple, I will be using a simple example. I have a Table with PersonName and DOB. I want access to send me email notification one day before someone's birthday. I have set up the query accordingly.
I have a problem with my code and saying something about 'Syntax Error' - My error lies here and I am not sure on how to move on.
Here is the full code: Can someone kindly help? Thank You!
Public Function fDOBNotices() As Boolean
Dim db As Database, rs As Recordset
Dim strTo As String, strSubject As String, strBody As String
Set db = CurrentDb()
Set rs = db.OpenRecordset("DOBNotification")
strTo = "sunramkissoon@apolloblake.com"
strSubject = "Birthday Notification"
rs.MoveFirst
Do While Not rs.EOF
strBody = "This is to inform you that " & rs.Fields("PersonName") & "will be celebrating their birthday tomorrow!"
DoCmd.SendObject(, , , strTo, , , strSubject, strBody)
rs.MoveNext
Loop
Set rs = Nothing
Set db = Nothing
End Function
To make it simple, I will be using a simple example. I have a Table with PersonName and DOB. I want access to send me email notification one day before someone's birthday. I have set up the query accordingly.
I have a problem with my code and saying something about 'Syntax Error' - My error lies here and I am not sure on how to move on.
Here is the full code: Can someone kindly help? Thank You!
Public Function fDOBNotices() As Boolean
Dim db As Database, rs As Recordset
Dim strTo As String, strSubject As String, strBody As String
Set db = CurrentDb()
Set rs = db.OpenRecordset("DOBNotification")
strTo = "sunramkissoon@apolloblake.com"
strSubject = "Birthday Notification"
rs.MoveFirst
Do While Not rs.EOF
strBody = "This is to inform you that " & rs.Fields("PersonName") & "will be celebrating their birthday tomorrow!"
DoCmd.SendObject(, , , strTo, , , strSubject, strBody)
rs.MoveNext
Loop
Set rs = Nothing
Set db = Nothing
End Function