PDA

View Full Version : Assigning Values to Contact User Variables



MWE
01-10-2010, 10:26 PM
I am running Outlook 2003. I have created several user variables for the contacts DB and created a new contact display form (NCDF) for most standard variables plus these new ones. Thus the MessageClass for contacts to be displayed with the new form (and user variables) is IPM.Contact.NCDF
I created and ran a VBA procedure to change the message class of any contact item that were IPM.Contact to IPM.Contact.NCDF

Case 1: I display a contact created before UserVariable "A" was created. Since its MessageClass is IPM.Contact.NCDF, the new form is used. The text box for "A" is blank (as it should be), I can edit the text box, etc., and if I save that contact and redisplay it, "A" is what it should be.

Case 2: I create a new contact using the normal (manual) process. IPM.Contact.NCDF is now the default, so, as above, "A" is blank, ... everything seems OK

Case 3: I create a new contact using a VBA procedure and assign values to standard contact variables, but not user variables. Everything works fine and when I display the contact all values are as they should be and all user variables are blank.

Case 4: I create a new contact using a VBA procedure and assign values to both standard contact variables and user variables. I make sure that the MessageClass of the new contact object is IPM.Contact.NCD I attempt to display the new contact and the original version of the contact form is presented. :dunno
I check the MessageClass of the contact and it is IPM.Contact.NCDF However, the value for all user variables is Null even those I explicitly set under VBA control. I exit Outlook and then restart Outlook. The just created contact now displays correctly with NCDF but all user variables are blank.
I modified the code that created the new contact and add a MsgBox output:
olContact.UserProperties("A") = "some text"
Msgbox olContact.UserProperties("A") the first line seems to execute. The 2nd line generates an error which I trace to the fact that olContact.UserProperties("A") is null

From all of this I have concluded several things:
User variables added to the Contact DB are valid only for contacts with the MessageClass ... seems strange
user variables do not seem to "exist" for a given contact (record) until that contact is displayed ... also seems strange

So, I split the VBA procedure that creates the new contact into two parts. The first creates the contact and assigns values to normal variables. The second assigns values to user variables. If I run the first and then run the second, I get the same results as Case 4 above. But if I run the first VBA proc, display the contact, close the display and then run the 2nd VBA proc, it seems to work.

Can anyone explain what might be going on here and how I can create the new contact and assign values to both standard and user variables without the intermediate step?

Thanks