Dear All,
I have created this code to alert users with automatic email
this is a function which i call to a click button.
I am using SQL SERVER back and ADP front
i face a problem
'gives me error on the below line (SET rs)it says
'Runtime-error "91"
'Object variable or with block variable not set"
'-------------------------------------------------------
Private Function fEmailNotification()
Dim rs As DAO.Recordset
Dim strEmailTo As String
Dim strSubject As String
Dim strMessage As String
strSubject = "Your Package Has Arrived"
strMessage = "Please come and pick up your package in the mailroom. Thanks"
'email notification
Set rs = CurrentDb.OpenRecordset("SELECT dbo.Tasks.ID, dbo.Tasks.Cris, dbo.Tasks.TaskM, dbo.Tasks.Date_Planed, dbo.Tasks.Task, dbo.Tasks.Date_Done, dbo.Tasks.Remarks,dbo.Tasks.Pending , dbo.Tasks.Next, dbo.Emails.Email FROM dbo.Tasks INNER JOIN dbo.Emails ON dbo.Tasks.TaskM = dbo.Emails.Nick_Name Where date_planed >= { fn NOW() }")
rs.MoveFirst
While Not rs.EOF
'Just in case there are multiple records that have been flagged...
If strEmailTo <> "" Then
strEmailTo = strEmailTo & "; " & rs!email
Else
strEmailTo = rs!email
End If
rs.MoveNext
Wend
DoCmd.SendObject , "", "", strEmailTo, "", "", strSubject, strMessage, False, ""
End Function
'-----------------------------------------------------
any idea
I have created this code to alert users with automatic email
this is a function which i call to a click button.
I am using SQL SERVER back and ADP front
i face a problem
'gives me error on the below line (SET rs)it says
'Runtime-error "91"
'Object variable or with block variable not set"
'-------------------------------------------------------
Private Function fEmailNotification()
Dim rs As DAO.Recordset
Dim strEmailTo As String
Dim strSubject As String
Dim strMessage As String
strSubject = "Your Package Has Arrived"
strMessage = "Please come and pick up your package in the mailroom. Thanks"
'email notification
Set rs = CurrentDb.OpenRecordset("SELECT dbo.Tasks.ID, dbo.Tasks.Cris, dbo.Tasks.TaskM, dbo.Tasks.Date_Planed, dbo.Tasks.Task, dbo.Tasks.Date_Done, dbo.Tasks.Remarks,dbo.Tasks.Pending , dbo.Tasks.Next, dbo.Emails.Email FROM dbo.Tasks INNER JOIN dbo.Emails ON dbo.Tasks.TaskM = dbo.Emails.Nick_Name Where date_planed >= { fn NOW() }")
rs.MoveFirst
While Not rs.EOF
'Just in case there are multiple records that have been flagged...
If strEmailTo <> "" Then
strEmailTo = strEmailTo & "; " & rs!email
Else
strEmailTo = rs!email
End If
rs.MoveNext
Wend
DoCmd.SendObject , "", "", strEmailTo, "", "", strSubject, strMessage, False, ""
End Function
'-----------------------------------------------------
any idea