The following code updates a Task based on the different fields I change re the Contact that is assigned to it.....so in my contact form, I have many fields that show up on the P2 folder of the Task......but, it only updates a Task where the contact name of the the task is my name....not any other contact I select....so what should we fix so it identifies any contact I select to update the task...as if it was my name three times, it updates all tasks for the three contacts of my name....so I just need to have it identify any contacts I select, not just my name....thanks much:
Sub Group_Update_Task2()
'Dim objApp As Application
'Dim objNS As NameSpace
'Dim objFolder As MAPIFolder
' Dim objMsg As MailItem
Dim ObjItem As Object
' Dim remoteObj
'Dim ContactName
' Dim olns
'Dim MyFolder
'Dim NumItems
' Dim myItems
'Dim TaskCount
Dim Str, Str1, Str2, Str3, Str4, Str5, Str6, Str7, Str8, Str9, Str10, Str11, Str12, Str13, Str14, Str15, Str16, Str17, Str18, Str19, Str20, Str21, Str22
Dim StartDate
Dim DueDate
Dim myItem
Set oContact = ObjItem
Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")
Set objSelection = objApp.ActiveExplorer.Selection
For Each ObjItem In objSelection
TaskCount = 0
Str = ObjItem.GetInspector.ModifiedFormPages("General").Controls("ComboBox7").value
Str1 = ObjItem.GetInspector.ModifiedFormPages("General").Controls("ComboBox8").value
Str2 = ObjItem.GetInspector.ModifiedFormPages("General").Controls("TextBox5").value
Str3 = ObjItem.GetInspector.ModifiedFormPages("General").Controls("Initial Intro").value
Str4 = ObjItem.GetInspector.ModifiedFormPages("General").Controls("Intro Date").value
Str5 = ObjItem.GetInspector.ModifiedFormPages("General").Controls("ComboBox10").value
Str6 = ObjItem.GetInspector.ModifiedFormPages("General").Controls("ComboBox3").value
Str7 = ObjItem.GetInspector.ModifiedFormPages("General").Controls("ComboBox2").value
Str8 = ObjItem.GetInspector.ModifiedFormPages("General").Controls("ComboBox4").value
Str9 = ObjItem.GetInspector.ModifiedFormPages("General").Controls("ComboBox5").value
Str10 = ObjItem.GetInspector.ModifiedFormPages("General").Controls("ContactTypeComboBox1").value
Str11 = ObjItem.GetInspector.ModifiedFormPages("General").Controls("TextBox4").value
Str12 = ObjItem.GetInspector.ModifiedFormPages("General").Controls("StatusComboBox1").value
Str13 = ObjItem.GetInspector.ModifiedFormPages("General").Controls("TextBox20").value
Str14 = ObjItem.GetInspector.ModifiedFormPages("General").Controls("ComboBox6").value
Str15 = ObjItem.GetInspector.ModifiedFormPages("General").Controls("TextBox22").value
Str16 = ObjItem.GetInspector.ModifiedFormPages("General").Controls("ComboBox9").value
Str17 = ObjItem.GetInspector.ModifiedFormPages("General").Controls("Follow-Up ComboBox1").value
Str18 = ObjItem.GetInspector.ModifiedFormPages("General").Controls("TextBox3").value
Str19 = ObjItem.GetInspector.ModifiedFormPages("General").Controls("NextStepComboBox1").value
Str20 = ObjItem.GetInspector.ModifiedFormPages("General").Controls("TextBox14").value
Str21 = ObjItem.GetInspector.ModifiedFormPages("General").Controls("ComboBox25").value
Str22 = ObjItem.GetInspector.ModifiedFormPages("General").Controls("TextBox29").value
StartDate = ObjItem.GetInspector.ModifiedFormPages("General").Controls("OlkDateControl4").value
DueDate = ObjItem.GetInspector.ModifiedFormPages("General").Controls("OlkDateControl3").value
ContactName = ObjItem.GetInspector.ModifiedFormPages("General").Controls("Fullname").value
Set olns = ObjItem.Application.GetNamespace("MAPI")
Set MyFolder = olns.GetDefaultFolder(13)
NumItems = MyFolder.items.Count
Set myItems = MyFolder.items
If NumItems > 0 Then
For i = 1 To NumItems
Set Recipients = myItems(i).Recipients
If Recipients.Count > 0 Then
If myItems(i).Links.Item(1).Name = ContactName Then
myItems(i).Display
myItems(i).GetInspector.ModifiedFormPages("P.2").Controls("TextBox20").value = Str
myItems(i).GetInspector.ModifiedFormPages("P.2").Controls("TextBox7").value = Str1
myItems(i).GetInspector.ModifiedFormPages("P.2").Controls("TextBox24").value = Str2
myItems(i).GetInspector.ModifiedFormPages("P.2").Controls("TextBox25").value = Str3
myItems(i).GetInspector.ModifiedFormPages("P.2").Controls("TextBox26").value = Str4
myItems(i).GetInspector.ModifiedFormPages("P.2").Controls("TextBox23").value = Str5
myItems(i).GetInspector.ModifiedFormPages("P.2").Controls("TextBox8").value = Str6
myItems(i).GetInspector.ModifiedFormPages("P.2").Controls("TextBox9").value = Str7
myItems(i).GetInspector.ModifiedFormPages("P.2").Controls("TextBox10").value = Str8
myItems(i).GetInspector.ModifiedFormPages("P.2").Controls("TextBox11").value = Str9
myItems(i).GetInspector.ModifiedFormPages("P.2").Controls("TextBox12").value = Str10
myItems(i).GetInspector.ModifiedFormPages("P.2").Controls("TextBox13").value = Str11
myItems(i).GetInspector.ModifiedFormPages("P.2").Controls("TextBox14").value = Str12
myItems(i).GetInspector.ModifiedFormPages("P.2").Controls("TextBox15").value = Str13
myItems(i).GetInspector.ModifiedFormPages("P.2").Controls("TextBox16").value = Str14
myItems(i).GetInspector.ModifiedFormPages("P.2").Controls("TextBox22").value = Str15
myItems(i).GetInspector.ModifiedFormPages("P.2").Controls("TextBox21").value = Str16
myItems(i).GetInspector.ModifiedFormPages("P.2").Controls("TextBox17").value = Str17
myItems(i).GetInspector.ModifiedFormPages("P.2").Controls("TextBox18").value = Str18
myItems(i).GetInspector.ModifiedFormPages("P.2").Controls("TextBox19").value = Str19
myItems(i).GetInspector.ModifiedFormPages("P.2").Controls("TextBox28").value = Str20
myItems(i).GetInspector.ModifiedFormPages("P.2").Controls("TextBox29").value = Str21
myItems(i).GetInspector.ModifiedFormPages("P.2").Controls("TextBox27").value = Str22
myItems(i).StartDate = StartDate
myItems(i).DueDate = DueDate
myItems(i).Save
myItems(i).Close (0)
TaskCount = TaskCount + 1
End If
End If
Next
End If
Select Case TaskCount
Case 0
MsgBox "No tasks were updated."
Case 1
MsgBox "One task was update successfully."
Case Else
MsgBox TaskCount & " tasks were updated successfully."
End Select
Next
Set objMsg = Nothing
Set ObjItem = Nothing
Set objFolder = Nothing
Set objNS = Nothing
Set objApp = Nothing
End Sub