hi, i need a help
i am trying to do markcomplete to task from a form but i get err -2147467259 the item could not be saved because it has been modified by another user or open in another window
my code is:
Sub DoneButton_Click()
OldTask = Item.UserProperties.Find("taskid1".Value
If OldTask<>"" Then
toDepartment = Item.UserProperties.Find("Taskdepartment".Value
' MsgBox"todep="& toDepartment
SetPublicFolder("pDepartment"
Set OldTaskFolder = gPublicFolder
Set MyWantedTask = OldTaskFolder.Items.Find _
("[BillingInformation]= '" & OldTask & "'"
If MyWantedTask Is Nothing Then 'task was already deleted
Else 'found
On Error Resume Next
Set OldTaskFolder = OldTaskFolder.Folders("Finished"
MyWantedTask.MarkComplete
If Err.Number <> 0 Then
MsgBox "Error get markcomplete . Err = " & Err.Number & " " & err.Description,,"SWAMP"
Else
MsgBox "seting oldtaskFolder was successffully"
End If
MyWantedTask.Save
'If Err.Number <> 0 Then
' MsgBox "Error save . Err = " & Err.Number & " " & err.Description,,"SWAMP"
'
' Else
' MsgBox "mail item was geting successffully"
' End If
'Set OldTaskFolder = OldTaskFolder.Folders("Finished"
' If Err.Number <> 0 Then
' MsgBox "Error get OldTaskFolder . Err = " & Err.Number & " " & err.Description,,"SWAMP"
'
' Else
' MsgBox "mail item was geting successffully"
' End If
MyWantedTask.Move OldTaskFolder
Set MyWantedTask = Nothing
End If
Set OldTaskFolder = Nothing
Item.UserProperties.Find("taskid1".Value = "" 'last task
End If
FormFolder = Item.UserProperties.Find("FormFolder".Value
Item.UserProperties.Find("Stage-".Value = "Finished"
Item.UserProperties.Find("DateOfDone".Value = Now()
MyNow = Now()
Item.UserProperties.Find("Implementation Approval Name-".Value = gMyName
MyHistory = "implementation done by " & gMyName & " at " & myNow
WriteHistory MyHistory
Item.Save
Set NewItem = Application.CreateItem(0)
If Err.Number <> 0 Then
MsgBox "Error get mail item. Err = " & Err.Number & " " & err.Description,,"SWAMP"
Else
MsgBox "mail item was geting successffully"
End If
SetPublicFolder("pproj"
Set MovedItem = Item.Move(gPublicFolder)
MovedItem.UserProperties.Find("IsOpen".Value = False
Finished = True
MovedItem.Save
code in the task is:
Sub Item_PropertyChange(ByVal Name)
MsgBox"name"&Name
Select Case Name
Case "Complete"
MsgBox"ira"
If Item.Complete = True Then
If Item.UserProperties.Find("OpenbyForm".Value = False Then
'Move task to Finished
MsgBox"ira2"
Set ThisFolder = Item.Parent
MsgBox"3"
'''''' Set ThisFolder = Application.ActiveExplorer.CurrentFolder
If ThisFolder.Name = "Finished" Then 'already moved
MsgBox"finished="&Finished
Item.Close 0 'save and close
Else
MsgBox"ira else"
Set NewFolder = ThisFolder.Folders("Finished"
If err.Number<>0 Then
Msgbox "Problem save folder. Err= " & err.Number & " " & err.Description,, "SWAMP"
End If
Set MovedItem =item.Move (NewFolder)
If err.Number<>0 Then
Msgbox "Problem save folder. Err= " & err.Number & " " & err.Description,, "SWAMP"
End If
MovedItem.UserProperties.Find("IsOpen".Value = False
Finished = True
MovedItem.Save
If err.Number<>0 Then
Msgbox "Problem save folder. Err= " & err.Number & " " & err.Description,, "SWAMP"
End If
MsgBox"after saving moved item"
'''' Item.Move(NewFolder)
Set NewFolder = nothing
MsgBox"new folder=nothin"
Set ThisFolder = nothing
MsgBox"this folder = nothing"
MsgBox"end of complete"
End If
End If
End If
End Select
End Sub
i am trying to do markcomplete to task from a form but i get err -2147467259 the item could not be saved because it has been modified by another user or open in another window
my code is:
Sub DoneButton_Click()
OldTask = Item.UserProperties.Find("taskid1".Value
If OldTask<>"" Then
toDepartment = Item.UserProperties.Find("Taskdepartment".Value
' MsgBox"todep="& toDepartment
SetPublicFolder("pDepartment"
Set OldTaskFolder = gPublicFolder
Set MyWantedTask = OldTaskFolder.Items.Find _
("[BillingInformation]= '" & OldTask & "'"
If MyWantedTask Is Nothing Then 'task was already deleted
Else 'found
On Error Resume Next
Set OldTaskFolder = OldTaskFolder.Folders("Finished"
MyWantedTask.MarkComplete
If Err.Number <> 0 Then
MsgBox "Error get markcomplete . Err = " & Err.Number & " " & err.Description,,"SWAMP"
Else
MsgBox "seting oldtaskFolder was successffully"
End If
MyWantedTask.Save
'If Err.Number <> 0 Then
' MsgBox "Error save . Err = " & Err.Number & " " & err.Description,,"SWAMP"
'
' Else
' MsgBox "mail item was geting successffully"
' End If
'Set OldTaskFolder = OldTaskFolder.Folders("Finished"
' If Err.Number <> 0 Then
' MsgBox "Error get OldTaskFolder . Err = " & Err.Number & " " & err.Description,,"SWAMP"
'
' Else
' MsgBox "mail item was geting successffully"
' End If
MyWantedTask.Move OldTaskFolder
Set MyWantedTask = Nothing
End If
Set OldTaskFolder = Nothing
Item.UserProperties.Find("taskid1".Value = "" 'last task
End If
FormFolder = Item.UserProperties.Find("FormFolder".Value
Item.UserProperties.Find("Stage-".Value = "Finished"
Item.UserProperties.Find("DateOfDone".Value = Now()
MyNow = Now()
Item.UserProperties.Find("Implementation Approval Name-".Value = gMyName
MyHistory = "implementation done by " & gMyName & " at " & myNow
WriteHistory MyHistory
Item.Save
Set NewItem = Application.CreateItem(0)
If Err.Number <> 0 Then
MsgBox "Error get mail item. Err = " & Err.Number & " " & err.Description,,"SWAMP"
Else
MsgBox "mail item was geting successffully"
End If
SetPublicFolder("pproj"
Set MovedItem = Item.Move(gPublicFolder)
MovedItem.UserProperties.Find("IsOpen".Value = False
Finished = True
MovedItem.Save
code in the task is:
Sub Item_PropertyChange(ByVal Name)
MsgBox"name"&Name
Select Case Name
Case "Complete"
MsgBox"ira"
If Item.Complete = True Then
If Item.UserProperties.Find("OpenbyForm".Value = False Then
'Move task to Finished
MsgBox"ira2"
Set ThisFolder = Item.Parent
MsgBox"3"
'''''' Set ThisFolder = Application.ActiveExplorer.CurrentFolder
If ThisFolder.Name = "Finished" Then 'already moved
MsgBox"finished="&Finished
Item.Close 0 'save and close
Else
MsgBox"ira else"
Set NewFolder = ThisFolder.Folders("Finished"
If err.Number<>0 Then
Msgbox "Problem save folder. Err= " & err.Number & " " & err.Description,, "SWAMP"
End If
Set MovedItem =item.Move (NewFolder)
If err.Number<>0 Then
Msgbox "Problem save folder. Err= " & err.Number & " " & err.Description,, "SWAMP"
End If
MovedItem.UserProperties.Find("IsOpen".Value = False
Finished = True
MovedItem.Save
If err.Number<>0 Then
Msgbox "Problem save folder. Err= " & err.Number & " " & err.Description,, "SWAMP"
End If
MsgBox"after saving moved item"
'''' Item.Move(NewFolder)
Set NewFolder = nothing
MsgBox"new folder=nothin"
Set ThisFolder = nothing
MsgBox"this folder = nothing"
MsgBox"end of complete"
End If
End If
End If
End Select
End Sub