Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

i am trying to do markcomplete to task from a form but i get err -2147

Status
Not open for further replies.

18121208

Programmer
Feb 2, 2003
1
IL
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<>&quot;&quot; Then
toDepartment = Item.UserProperties.Find(&quot;Taskdepartment&quot;).Value
' MsgBox&quot;todep=&quot;& toDepartment
SetPublicFolder(&quot;pDepartment&quot;)
Set OldTaskFolder = gPublicFolder


Set MyWantedTask = OldTaskFolder.Items.Find _
(&quot;[BillingInformation]= '&quot; & OldTask & &quot;'&quot;)

If MyWantedTask Is Nothing Then 'task was already deleted
Else 'found
On Error Resume Next
Set OldTaskFolder = OldTaskFolder.Folders(&quot;Finished&quot;)
MyWantedTask.MarkComplete
If Err.Number <> 0 Then
MsgBox &quot;Error get markcomplete . Err = &quot; & Err.Number & &quot; &quot; & err.Description,,&quot;SWAMP&quot;

Else
MsgBox &quot;seting oldtaskFolder was successffully&quot;
End If

MyWantedTask.Save
'If Err.Number <> 0 Then
' MsgBox &quot;Error save . Err = &quot; & Err.Number & &quot; &quot; & err.Description,,&quot;SWAMP&quot;
'
' Else
' MsgBox &quot;mail item was geting successffully&quot;
' End If

'Set OldTaskFolder = OldTaskFolder.Folders(&quot;Finished&quot;)
' If Err.Number <> 0 Then
' MsgBox &quot;Error get OldTaskFolder . Err = &quot; & Err.Number & &quot; &quot; & err.Description,,&quot;SWAMP&quot;
'
' Else
' MsgBox &quot;mail item was geting successffully&quot;
' End If


MyWantedTask.Move OldTaskFolder

Set MyWantedTask = Nothing
End If
Set OldTaskFolder = Nothing
Item.UserProperties.Find(&quot;taskid1&quot;).Value = &quot;&quot; 'last task
End If

FormFolder = Item.UserProperties.Find(&quot;FormFolder&quot;).Value
Item.UserProperties.Find(&quot;Stage-&quot;).Value = &quot;Finished&quot;
Item.UserProperties.Find(&quot;DateOfDone&quot;).Value = Now()
MyNow = Now()
Item.UserProperties.Find(&quot;Implementation Approval Name-&quot;).Value = gMyName
MyHistory = &quot;implementation done by &quot; & gMyName & &quot; at &quot; & myNow
WriteHistory MyHistory
Item.Save
Set NewItem = Application.CreateItem(0)
If Err.Number <> 0 Then
MsgBox &quot;Error get mail item. Err = &quot; & Err.Number & &quot; &quot; & err.Description,,&quot;SWAMP&quot;

Else
MsgBox &quot;mail item was geting successffully&quot;
End If


SetPublicFolder(&quot;pproj&quot;)

Set MovedItem = Item.Move(gPublicFolder)

MovedItem.UserProperties.Find(&quot;IsOpen&quot;).Value = False
Finished = True
MovedItem.Save


code in the task is:

Sub Item_PropertyChange(ByVal Name)
MsgBox&quot;name&quot;&Name

Select Case Name

Case &quot;Complete&quot;
MsgBox&quot;ira&quot;
If Item.Complete = True Then

If Item.UserProperties.Find(&quot;OpenbyForm&quot;).Value = False Then
'Move task to Finished
MsgBox&quot;ira2&quot;
Set ThisFolder = Item.Parent
MsgBox&quot;3&quot;

'''''' Set ThisFolder = Application.ActiveExplorer.CurrentFolder
If ThisFolder.Name = &quot;Finished&quot; Then 'already moved
MsgBox&quot;finished=&quot;&Finished
Item.Close 0 'save and close
Else
MsgBox&quot;ira else&quot;
Set NewFolder = ThisFolder.Folders(&quot;Finished&quot;)
If err.Number<>0 Then
Msgbox &quot;Problem save folder. Err= &quot; & err.Number & &quot; &quot; & err.Description,, &quot;SWAMP&quot;
End If
Set MovedItem =item.Move (NewFolder)
If err.Number<>0 Then
Msgbox &quot;Problem save folder. Err= &quot; & err.Number & &quot; &quot; & err.Description,, &quot;SWAMP&quot;
End If
MovedItem.UserProperties.Find(&quot;IsOpen&quot;).Value = False
Finished = True

MovedItem.Save
If err.Number<>0 Then
Msgbox &quot;Problem save folder. Err= &quot; & err.Number & &quot; &quot; & err.Description,, &quot;SWAMP&quot;
End If

MsgBox&quot;after saving moved item&quot;
'''' Item.Move(NewFolder)

Set NewFolder = nothing
MsgBox&quot;new folder=nothin&quot;

Set ThisFolder = nothing
MsgBox&quot;this folder = nothing&quot;

MsgBox&quot;end of complete&quot;
End If
End If
End If
End Select

End Sub



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top