delete task

J

Joy

in my macros, if user is to delete a task with actual work or the task is
complete, I will give a msg to let the user choose whether or not to delete it

the problem is: each time the msg prompts, after that the MS project will
also give a msgbox saying that the task has actual data, do you want to
delete it?

I am wondering how I can just let it show my own msgbox. I do not want to
let the msgbox show twice, which may make users not happy.


my codes:
' tsk is complete
If (tsk.PercentComplete = 100) Then
If MsgBox("Are you sure you want to delete the task? " _
& vbCrLf & Chr(13) & "It has been marked as complete.", vbYesNo +
vbCritical) = vbNo Then
Cancel = True
Exit Sub

Else

End If
' actual work >0
ElseIf Not (Left(tsk.ActualWork, 1) = "0") Then
If MsgBox("Are you sure you want to delete the task? " _
& vbCrLf & Chr(13) & "It has actual work. ", vbYesNo + vbCritical)
= vbNo Then
Cancel = True
Exit Sub

Else
Exit Sub
End If





thanks
 
J

John

Joy said:
in my macros, if user is to delete a task with actual work or the task is
complete, I will give a msg to let the user choose whether or not to delete it

the problem is: each time the msg prompts, after that the MS project will
also give a msgbox saying that the task has actual data, do you want to
delete it?

I am wondering how I can just let it show my own msgbox. I do not want to
let the msgbox show twice, which may make users not happy.


my codes:
' tsk is complete
If (tsk.PercentComplete = 100) Then
If MsgBox("Are you sure you want to delete the task? " _
& vbCrLf & Chr(13) & "It has been marked as complete.", vbYesNo +
vbCritical) = vbNo Then
Cancel = True
Exit Sub

Else

End If
' actual work >0
ElseIf Not (Left(tsk.ActualWork, 1) = "0") Then
If MsgBox("Are you sure you want to delete the task? " _
& vbCrLf & Chr(13) & "It has actual work. ", vbYesNo + vbCritical)
= vbNo Then
Cancel = True
Exit Sub

Else
Exit Sub
End If





thanks

Joy,
I don't remember if that particular message is an option, (i.e. can be
turned on or off), but you can give it a try. Whether or not to display
messages is under Tools/Options/[various tabs]. In VBA, those options
are controlled by one of the Options[whatever] Methods.

Hope this helps.
John
Project MVP
 
J

Joy

Thank you, John

John said:
Joy said:
in my macros, if user is to delete a task with actual work or the task is
complete, I will give a msg to let the user choose whether or not to delete it

the problem is: each time the msg prompts, after that the MS project will
also give a msgbox saying that the task has actual data, do you want to
delete it?

I am wondering how I can just let it show my own msgbox. I do not want to
let the msgbox show twice, which may make users not happy.


my codes:
' tsk is complete
If (tsk.PercentComplete = 100) Then
If MsgBox("Are you sure you want to delete the task? " _
& vbCrLf & Chr(13) & "It has been marked as complete.", vbYesNo +
vbCritical) = vbNo Then
Cancel = True
Exit Sub

Else

End If
' actual work >0
ElseIf Not (Left(tsk.ActualWork, 1) = "0") Then
If MsgBox("Are you sure you want to delete the task? " _
& vbCrLf & Chr(13) & "It has actual work. ", vbYesNo + vbCritical)
= vbNo Then
Cancel = True
Exit Sub

Else
Exit Sub
End If





thanks

Joy,
I don't remember if that particular message is an option, (i.e. can be
turned on or off), but you can give it a try. Whether or not to display
messages is under Tools/Options/[various tabs]. In VBA, those options
are controlled by one of the Options[whatever] Methods.

Hope this helps.
John
Project MVP
 
J

John

Joy said:
Thank you, John

Joy,
You're welcome and thanks for the feedback.
John
John said:
Joy said:
in my macros, if user is to delete a task with actual work or the task is
complete, I will give a msg to let the user choose whether or not to
delete it

the problem is: each time the msg prompts, after that the MS project will
also give a msgbox saying that the task has actual data, do you want to
delete it?

I am wondering how I can just let it show my own msgbox. I do not want to
let the msgbox show twice, which may make users not happy.


my codes:
' tsk is complete
If (tsk.PercentComplete = 100) Then
If MsgBox("Are you sure you want to delete the task? " _
& vbCrLf & Chr(13) & "It has been marked as complete.", vbYesNo
+
vbCritical) = vbNo Then
Cancel = True
Exit Sub

Else

End If
' actual work >0
ElseIf Not (Left(tsk.ActualWork, 1) = "0") Then
If MsgBox("Are you sure you want to delete the task? " _
& vbCrLf & Chr(13) & "It has actual work. ", vbYesNo +
vbCritical)
= vbNo Then
Cancel = True
Exit Sub

Else
Exit Sub
End If





thanks

Joy,
I don't remember if that particular message is an option, (i.e. can be
turned on or off), but you can give it a try. Whether or not to display
messages is under Tools/Options/[various tabs]. In VBA, those options
are controlled by one of the Options[whatever] Methods.

Hope this helps.
John
Project MVP
 

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