Check For Status of Record

  • Thread starter Thread starter charles bosen via AccessMonster.com
  • Start date Start date
C

charles bosen via AccessMonster.com

I have a status drop-down on my form. I need to send an email to a person
when the status is changed to closed. My code is not working.

Can anyone help me with this?? Here's my code:

Private Sub Status_AfterUpdate()
Me.Status = Status

If Me.Status = closed Then
' If closed, Notify person reported'
MsgBox "Person Reported this Issue Is Notified"
DoCmd.SendObject acSendNoObject, , , Me.Reportedby, , , "Discrepancy Issue
Tracking No: " & Me.TrackingNo & "", "THIS ISSUE HAS BEEN CLOSED. -
Closed Date: " & Date & """"

Else
Exit Sub
End If
End Sub
 
you start the sub by asyning a value of status to me.status, so how can you
check in second line if me.status = closed, the code just changed it value to
status.
So it probably never pass the if condition, and it never send the mail.
 
Hi Ofer

The "Status" field is a drop-down that lists (open, closed, in progress).
What I'm trying to check for is if the status=closed then send the email.
Only if the status is closed will the email fire off. Otherwise exit the
sub.

Thanks,
CB
 
Try removing the first line, try this code
Private Sub Status_AfterUpdate()
' Me.Status = Status - I dont know what status eaual to.

If Me.Status = closed Then
' If closed, Notify person reported'
MsgBox "Person Reported this Issue Is Notified"
DoCmd.SendObject acSendNoObject, , , Me.Reportedby, , , "Discrepancy Issue
Tracking No: " & Me.TrackingNo, "THIS ISSUE HAS BEEN CLOSED. -
Closed Date: " & Date
Else
Exit Sub
End If
End Sub
 
Back
Top