I have an application that uses custom forms to create task items (with custom fields) and place them in a specific folder.
There are several date fields within these items, some of which are filled automatically, some are entered by the user.
I have a problem with some of the auto-filled dates. They have been using full date serial numbers, including the date AND time. I don't want these to include the time part. I have corrected the form accordingly, and any new items will only take the date part.
My problem is that I want to amend the dates for existing items. I have written a one off piece of code to correct these. However it doesn't seem to be working. I have included MsgBox lines to report on one field so that I can see what's happening. These messages show it to be amending the dates correctly, but if you change the view, or run again, you can see that it hasn't changed the values.
The code I have used is:
Dim MyNameSpace
Dim TheFolders
Dim anInBox
Dim SpecificFolder
Dim dRequest
Dim dAuthorise
Dim dImplement
Dim dReview
Sub UpdateDates_Click
Set MyNameSpace = Application.GetNameSpace("MAPI"
Set TheFolders = MyNameSpace.Folders("Mailbox - Hardy, Simon"
Set anInBox = TheFolders.Folders("Inbox"
Set SpecificFolder = anInbox.Folders("JMC Change Control"
For Each oItem in SpecificFolder.Items
If oItem.UserProperties.Find("Requested On".Value <> Int(oItem.UserProperties.Find("Requested On".Value) Then
MsgBox "Original Date: " & oItem.UserProperties.Find("Requested On".Value
dRequest = Int(oItem.UserProperties.Find("Requested On".Value)
dAuthorise = Int(oItem.UserProperties.Find("Authorise By".Value)
dImplement = Int(oItem.UserProperties.Find("Implement By".Value)
dReview = Int(oItem.UserProperties.Find("Review By".Value)
MsgBox "Replace With: " & dRequest
oItem.UserProperties.Find("Requested On".Value = None
oItem.UserProperties.Find("Authorise By".Value = None
oItem.UserProperties.Find("Implement By".Value = None
oItem.UserProperties.Find("Review By".Value = None
MsgBox "Null Date?: " & oItem.UserProperties.Find("Requested On".Value
oItem.UserProperties.Find("Requested On".Value = Int(dRequest)
oItem.UserProperties.Find("Authorise By".Value = Int(dAuthorise)
oItem.UserProperties.Find("Implement By".Value = Int(dImplement)
oItem.UserProperties.Find("Review By".Value = Int(dReview)
MsgBox "New Val: " & oItem.UserProperties.Find("Requested On".Value
End If
Next
Item.Close 1
End Sub
Please help! I do not understand why this is not updating.
There are several date fields within these items, some of which are filled automatically, some are entered by the user.
I have a problem with some of the auto-filled dates. They have been using full date serial numbers, including the date AND time. I don't want these to include the time part. I have corrected the form accordingly, and any new items will only take the date part.
My problem is that I want to amend the dates for existing items. I have written a one off piece of code to correct these. However it doesn't seem to be working. I have included MsgBox lines to report on one field so that I can see what's happening. These messages show it to be amending the dates correctly, but if you change the view, or run again, you can see that it hasn't changed the values.
The code I have used is:
Dim MyNameSpace
Dim TheFolders
Dim anInBox
Dim SpecificFolder
Dim dRequest
Dim dAuthorise
Dim dImplement
Dim dReview
Sub UpdateDates_Click
Set MyNameSpace = Application.GetNameSpace("MAPI"
Set TheFolders = MyNameSpace.Folders("Mailbox - Hardy, Simon"
Set anInBox = TheFolders.Folders("Inbox"
Set SpecificFolder = anInbox.Folders("JMC Change Control"
For Each oItem in SpecificFolder.Items
If oItem.UserProperties.Find("Requested On".Value <> Int(oItem.UserProperties.Find("Requested On".Value) Then
MsgBox "Original Date: " & oItem.UserProperties.Find("Requested On".Value
dRequest = Int(oItem.UserProperties.Find("Requested On".Value)
dAuthorise = Int(oItem.UserProperties.Find("Authorise By".Value)
dImplement = Int(oItem.UserProperties.Find("Implement By".Value)
dReview = Int(oItem.UserProperties.Find("Review By".Value)
MsgBox "Replace With: " & dRequest
oItem.UserProperties.Find("Requested On".Value = None
oItem.UserProperties.Find("Authorise By".Value = None
oItem.UserProperties.Find("Implement By".Value = None
oItem.UserProperties.Find("Review By".Value = None
MsgBox "Null Date?: " & oItem.UserProperties.Find("Requested On".Value
oItem.UserProperties.Find("Requested On".Value = Int(dRequest)
oItem.UserProperties.Find("Authorise By".Value = Int(dAuthorise)
oItem.UserProperties.Find("Implement By".Value = Int(dImplement)
oItem.UserProperties.Find("Review By".Value = Int(dReview)
MsgBox "New Val: " & oItem.UserProperties.Find("Requested On".Value
End If
Next
Item.Close 1
End Sub
Please help! I do not understand why this is not updating.