crystalnewbie
MIS
Access 2000 / Outlook 2000
I have an Access contact form in which I would like to add a command button that will save the current contact to Microsoft Outlook Contacts or update and existing contact.
I've read through the FAQ and posts and got the following code on how to do this. The problem that I have now is that its only adding and not doing an update. Every time I hit the command button it adds a new contact regardless it the contact already exists.
Can't seem to find any docs on doing just an update. Any help is greatly appreciated.
Thanks in advance.
P.S. Also, instead of hardcoding the mailbox name (eg. Mailbox - Doe, John) is there a generic name/value to replace this?
---------------------
Private Sub AddToOutlook_Click()
Dim OutlookObj As Outlook.Application
Dim Nms As Outlook.namespace
Dim myContacts As Object
Dim myItems As Object
Dim MyItem As Object
'Dim DB As Database
Dim Rst As Recordset
Set Rst = Me.Recordset
Set OutlookObj = CreateObject("Outlook.application")
Set Nms = OutlookObj.GetNameSpace("MAPI")
Set myContacts = Nms.Folders.Item("Mailbox - Doe, John").Folders.Item("Test Contacts")
Set myItems = myContacts.items
Set MyItem = myItems.add("IPM.Contact.MyContactForm")
With MyItem
.FullName = Me![Name].Value
.CompanyName = Me![Company].Value
.Close (olSave)
End With
End Sub
I have an Access contact form in which I would like to add a command button that will save the current contact to Microsoft Outlook Contacts or update and existing contact.
I've read through the FAQ and posts and got the following code on how to do this. The problem that I have now is that its only adding and not doing an update. Every time I hit the command button it adds a new contact regardless it the contact already exists.
Can't seem to find any docs on doing just an update. Any help is greatly appreciated.
Thanks in advance.
P.S. Also, instead of hardcoding the mailbox name (eg. Mailbox - Doe, John) is there a generic name/value to replace this?
---------------------
Private Sub AddToOutlook_Click()
Dim OutlookObj As Outlook.Application
Dim Nms As Outlook.namespace
Dim myContacts As Object
Dim myItems As Object
Dim MyItem As Object
'Dim DB As Database
Dim Rst As Recordset
Set Rst = Me.Recordset
Set OutlookObj = CreateObject("Outlook.application")
Set Nms = OutlookObj.GetNameSpace("MAPI")
Set myContacts = Nms.Folders.Item("Mailbox - Doe, John").Folders.Item("Test Contacts")
Set myItems = myContacts.items
Set MyItem = myItems.add("IPM.Contact.MyContactForm")
With MyItem
.FullName = Me![Name].Value
.CompanyName = Me![Company].Value
.Close (olSave)
End With
End Sub