Problem using CDO to change Due by date in custom form

D

DArhelger

I'm using CDO to update the "Flag for Follow Up" fields in a custom
contact form in a public folder. This works just fine, except
sometimes I get conflicting edits. The problem appears to be that
while the new date in the Due By field is getting saved, it is not
getting displayed, even though I close the item, dereference it, and
reopen it. A subsequent change and save to the displayed item will
cause the original date to be saved, resulting in a conflicting edit.
What's even more bizarre is this is a Heisenburg bug: if I single-step
through the code, the Due By date in the open item is displayed
correctly.

Below is most of the pertinent code (error checking and other items
removed.)

Set objItem = objApp.ActiveInspector.CurrentItem
' make some changes here to other fields
' calculate newDate
objItem.Save

If g_CDOSession Is Nothing Then
Call DoCDOLogon
End If

Set objCDO = GetCDOItemFromOL(objItem)

Set olFields = objCDO.Fields
olFields.Item(CdoPR_FLAG_STATUS).Value = flagColor
olFields.Item(CdoPR_FLAG_TEXT).Value = "Follow up"
olFields.Item(CdoPR_REPLY_TIME).Value = newDate
olFields.Item(CdoPR_FLAG_DUE_BY).Value = newDate
olFields.Item(CdoPR_FLAG_DUE_BY_NEXT).Value = newDate

objCDO.Update True, True
objItem.Update True, True

objItem.Close olSave
Set objItem = Nothing
Set objItem = objApp.ActiveExplorer.Selection.Item(1)
objItem.Display

Help! Any ideas out there? I'm running Outlook 2003, Exchange 2003,
XP2, all patches applied.
 
D

darhelger

Addendum to my previous message:

The problem really is of a Heisenburg nature, but the difference is in how I
invoke the macro. If I single-step through, hand-create a toolbar button, or
execute it through Tools --> Macros, it works (and the Due By date is
updated in the re-displayed item). However, if I execute using a toolbar
built with the following code, the Due By date does not get updated in the
item display.

Function CreateCRMfuToolbar() As Office.CommandBar

Dim objApp As Outlook.Application
Dim objCBs As Office.CommandBars
Dim objCB As Office.CommandBar
Dim objCBControls As Office.CommandBarControls
Dim objControl As Office.CommandBarControl
On Error Resume Next
Set objApp = CreateObject("Outlook.Application")
Set objCBs = objApp.ActiveInspector.CommandBars
Set objCB = objCBs.Add("FollowUpBar", msoBarFloating)

objCB.Visible = True

Set objControl = objCBControls.Add(msoControlButton)
With objControl
.AddItem
.Caption = "SetNextFUDate"
.FaceId = 33
.OnAction = "setNextFUDate"
.Style = msoButtonIconAndCaption
.TooltipText = "Set Next Follow Up Date"
.Visible = True
End With

Set objControl = Nothing
Set objCBControls = Nothing
Set objCB = Nothing
Set objCBs = Nothing
Set objApp = Nothing

End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top