Event handling and conflicts in updating a CDO property

D

darhelger

I'm using CDO to update the "Flag for Follow Up" properties in a custom
contact form in a public folder.
After the update, I even close the item, dereference it, and reopen it to
make sure that any subsequent
changes made by the user don't cause conflicting edits. This works just fine
if I invoke the macro from
the VBA window, via Tools-->Macro, or hand build a toolbar button.

However, if I use the code below to create a new button in a new toolbar,
and click on the button to
fire the macro, I get conflicting edits. The information store is getting
updated (I can see the new values
in the folder view), but the update is not displayed in the item view. If
the user then makes a change to
the item and saves it, it causes conflicting edits, one item with the
original Due By date and other
Follow Up Flag information and the user's edits, the other item with the
updated flag information and
no new edits. (A Save & Close without a subsequent edit doesn't cause a
conflicting edit.)

I suspect the problem has to do with the event handling. Is the menu bar
code capturing a
PropertyChange event, and somehow impacting the display of the item? If so,
how do I resolve?
If not, what else could be causing this behavior?

Here's the toolbar code:

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

Many thanks,

DArhelger
 
M

Michael Bauer

What happens if you click on your code-builded button? Did you check if
your macro starts?
Dim objControl As Office.CommandBarControl

For receiving the click events you need to declare the variable
"WithEvents" in the head of your form and you need to declare it as
CommandBarButton, because the -Control doesn´t fire any event.
 
D

darhelger

Yes, the macro starts and runs to completion. All the click event has to do
is run the macro, which it does.

What I suspect is that adding the additional event handling layer of the
custom button somehow mucking with the item refresh so the property change
doesn't get displayed (although it is stored).

DArhelger
 
M

Michael Bauer

Sorry, my fault, I can´t help you.

I have read your posting yesterday a few times, this morning again but I
don´t understand the context. :-(
 

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