error popup coming unnecessarily

  • Thread starter Thread starter Dickery1
  • Start date Start date
D

Dickery1

Hello
I have a fully working code but for some reason it still triggers the
err block. can someone tell me why. I get a msgbox with Error 0 in it.
i thoght that they get triggered only if there is a error.


Sub MovePastDate2Today()
On Error GoTo MovePastDate2Today_Error
Dim t As TaskItem
Set f =
Application.GetNamespace("MAPI").GetDefaultFolder(olFolderTasks)
strText = ""
For Each t In f.Items
If (t.DueDate < Date And Not (t.Status = olTaskComplete)) Then
'strText = strText & (t.DueDate) & " "
t.DueDate = Date
t.Save

End If
Next

'MsgBox strText
'MsgBox Date




MovePastDate2Today_Error:
MsgBox "Error " & Err.Number & "(" & Err.Description & ")"




End Sub
 
Either put an Exit Sub statement before the Error: block or put the MsgBox inside an If Err <> 0 ... End If block. Code execution is going right through your Error: block.
 
Back
Top