Write to a custom field 
Author Message
 Write to a custom field

I want to import some data into Outlook from a MS Access database.

I'll need to write to some custom fields that are already defined in
Outlook.  I've been reviewing some of the posts in this newsgroup
regarding the use of userproperties and found them to be really helpful.

However while I can write to these fields I'm stuck on writing to them.
The write seems to go okay (no errors and I can print it to the debug
window) but when I open the form I ad look at the custom field it is
blank or contains old info.

I wrote the following subroutinue as test:

Public Sub Test()
Dim OL As Outlook.Application
Dim NS As NameSpace
Dim CF As MAPIFolder
Dim C As Outlook.ContactItem
Dim i As Object

Set OL = CreateObject("Outlook.Application")
Set NS = OL.GetNamespace("MAPI")
Set CF = NS.GetDefaultFolder(olFolderContacts)

Dim x As Integer
x = 1
For Each i In CF.Items
    Set C = CF.Items(x)
    x = x + 1
    'Set PR = C.UserProperties.Add("Test", olText)

    If C.UserProperties.Item("User Field 1") = 51 Then
        C.UserProperties.Item("Test").Value = "Hello"
        Debug.Print C.FullName, C.UserProperties.Item("Test")
    End If

Next i
End Sub

To test it I've changed the value of the test field on the form to "Good
bye".  Then I run this and it outputs that the value is now "Hello".
However, when I open the form, the value is still "Good bye".

Any help on this would be appreciated.

Thanks in advance,
Frank

*** Sent via Developersdex http://www.*-*-*.com/ ***
Don't just participate in USENET...get rewarded for it!



Fri, 04 Mar 2005 22:08:38 GMT  
 Write to a custom field
You're going to kick yourself. You forgot to save the item after you changed
properties:

    C.Save

--
Sue Mosher, Outlook MVP
Outlook and Exchange solutions at http://www.slipstick.com
Author of
     Microsoft Outlook Programming Jumpstart - coming September 2002
     http://www.slipstick.com/books/jumpstart.htm


Quote:
> I want to import some data into Outlook from a MS Access database.

> I'll need to write to some custom fields that are already defined in
> Outlook.  I've been reviewing some of the posts in this newsgroup
> regarding the use of userproperties and found them to be really helpful.

> However while I can write to these fields I'm stuck on writing to them.
> The write seems to go okay (no errors and I can print it to the debug
> window) but when I open the form I ad look at the custom field it is
> blank or contains old info.

> I wrote the following subroutinue as test:

> Public Sub Test()
> Dim OL As Outlook.Application
> Dim NS As NameSpace
> Dim CF As MAPIFolder
> Dim C As Outlook.ContactItem
> Dim i As Object

> Set OL = CreateObject("Outlook.Application")
> Set NS = OL.GetNamespace("MAPI")
> Set CF = NS.GetDefaultFolder(olFolderContacts)

> Dim x As Integer
> x = 1
> For Each i In CF.Items
>     Set C = CF.Items(x)
>     x = x + 1
>     'Set PR = C.UserProperties.Add("Test", olText)

>     If C.UserProperties.Item("User Field 1") = 51 Then
>         C.UserProperties.Item("Test").Value = "Hello"
>         Debug.Print C.FullName, C.UserProperties.Item("Test")
>     End If

> Next i
> End Sub

> To test it I've changed the value of the test field on the form to "Good
> bye".  Then I run this and it outputs that the value is now "Hello".
> However, when I open the form, the value is still "Good bye".

> Any help on this would be appreciated.

> Thanks in advance,
> Frank

> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!



Fri, 04 Mar 2005 22:35:34 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Writing to a Custom Field

2. Writing on a custom field of a form with CDO

3. Recurring-event Custom Meeting Forms Don't save custom fields

4. Setting values to Custom Fields on Custom Forms

5. Custom Field Value Lists on Custom Forms

6. Custom Fields in Custom Forms

7. Passing the validated fields value to custom method in a field level validation

8. Changing the Default duration field to a custom duration field

9. Help - writing to text field / database field

10. Writing Custom properties in VBA?

11. create custom icon,custom combobox in custom toolbar

12. create custom icon,custom combobox(to insert values)in custom toolbar

 

 
Powered by phpBB® Forum Software