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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Outlook98 - Correcting Field Values

Status
Not open for further replies.

SHardy

Programmer
May 9, 2001
231
GB
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(&quot;Requested On&quot;).Value <> Int(oItem.UserProperties.Find(&quot;Requested On&quot;).Value) Then

MsgBox &quot;Original Date: &quot; & oItem.UserProperties.Find(&quot;Requested On&quot;).Value

dRequest = Int(oItem.UserProperties.Find(&quot;Requested On&quot;).Value)
dAuthorise = Int(oItem.UserProperties.Find(&quot;Authorise By&quot;).Value)
dImplement = Int(oItem.UserProperties.Find(&quot;Implement By&quot;).Value)
dReview = Int(oItem.UserProperties.Find(&quot;Review By&quot;).Value)

MsgBox &quot;Replace With: &quot; & dRequest

oItem.UserProperties.Find(&quot;Requested On&quot;).Value = None
oItem.UserProperties.Find(&quot;Authorise By&quot;).Value = None
oItem.UserProperties.Find(&quot;Implement By&quot;).Value = None
oItem.UserProperties.Find(&quot;Review By&quot;).Value = None

MsgBox &quot;Null Date?: &quot; & oItem.UserProperties.Find(&quot;Requested On&quot;).Value

oItem.UserProperties.Find(&quot;Requested On&quot;).Value = Int(dRequest)
oItem.UserProperties.Find(&quot;Authorise By&quot;).Value = Int(dAuthorise)
oItem.UserProperties.Find(&quot;Implement By&quot;).Value = Int(dImplement)
oItem.UserProperties.Find(&quot;Review By&quot;).Value = Int(dReview)

MsgBox &quot;New Val: &quot; & oItem.UserProperties.Find(&quot;Requested On&quot;).Value

End If

Next

Item.Close 1

End Sub

Please help! I do not understand why this is not updating.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top