Find outlook contact and update, or add new

Posted on 2006-03-29
Last Modified: 2012-06-27
Access and Outlook 2003 using Outlook 11.0 Object Library reference

I've spent quite a long time searching for a way to add contacts to outlook programmatically from an access form.  I was successful in adding new contacts with data from the current record on the form.  The problem is, if the contact already exists, it will create a duplicate contact.  What I can't figure out is how to check if the contact exists.  

This is basically what I want to do (the code is not all there but I hope you get the idea):

If the contact exists then

  Dim Update_Contact As Integer
  Update_Contact = MsgBox("Contact Found." & vbCrLf & "Do you want to update the contact information?", vbYesNoCancel)
  Select Case Update_Contact
    Case vbYes
        'open the contact
        'update with contact info from the current record
        'save the contact
        exit sub
    Case vbNo
        'open the contact to view
        exit sub
    Case vbCancel
        exit sub
  End Select


  'add new contact with info from the current record
  'save the contact

End If

I Just need to know how to check if the contact exists, I have the rest of it worked out already.


Question by:traigo
    LVL 1

    Accepted Solution

    I use this bit of code to see if they exist and then if they dont I then add a new one  

      For Each obj In objItems
            If obj.Class = olContact Then
                Set objContact = obj
                    If objContact.FirstName = rst.Fields("FirstName") And objContact.LastName = rst.Fields("Surname") Then
                        With objContact
                            .CompanyName = rst.Fields("Company")
                            .FirstName = rst.Fields("FirstName")
                            .LastName = rst.Fields("Surname")
                            .BusinessAddress = rst.Fields("Address") & Chr(13) & rst.Fields("Suburb") & Chr(13) & rst.Fields("City")
                            .Body = rst.Fields("Description")
                            .BusinessFaxNumber = rst.Fields("Fax")
                            .Email1Address = rst.Fields("Email")
                            .MobileTelephoneNumber = rst.Fields("Mobile")
                            .BusinessTelephoneNumber = rst.Fields("Phone")
                            count = count + 1
                            rst.Fields("update") = False  ' this is used fro tracking what has been changed in the database
                        End With
                    End If
            End If
        Next obj

    Author Comment

    thanks for the quick response jimcrint.  I will try it first thing in the morning and post back

    Author Comment

    GREAT! THANKS!  I was able to get it working.

    If you are familiar with the calendar object too, keep an eye out, I may be posting with questions on that soon too.

    Thanks again,


    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Join & Write a Comment

    When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
    I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
    As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now