error popup coming unnecessarily

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
 
S

Sue Mosher [MVP-Outlook]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top