Results 1 to 5 of 5
  1. #1
    Star Lounger
    Join Date
    Jul 2002
    Location
    Petersburg, Virginia
    Posts
    54
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Copying Access records to Outlook (XP sp2)

    I ran code in Access that is supposed to copy records (name, address, etc.) from an Access table into Outlook Contacts. Instead, my Contacts fills up with 30-40 people all of whom live in Woodinville, WA. What's going on?

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Copying Access records to Outlook (XP sp2)

    This is a difficult one to discuss without seeing the code and knowing more about the database. Are there not a bunch of people from that city in the database?

  3. #3
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: Copying Access records to Outlook (XP sp2)

    You probably have a mapping error. WOODINVILLE WA is associated with ZIP Codes 98072 & 98077, but these are not the highest Zip codes, Alaska has the 99 series. Perhaps Woodinville is the highest zip code in the contiguous 48 states. As Jefferson notes, you need to post the code, or you could reverse engineer your mapping by doing a contact export to Access and comparing the two sets of fields.
    -John ... I float in liquid gardens
    UTC -7ąDS

  4. #4
    Star Lounger
    Join Date
    Jul 2002
    Location
    Petersburg, Virginia
    Posts
    54
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Copying Access records to Outlook (XP sp2)

    Here is the code located in module:

    Function ap_CreateOLContacts()

    Dim objContactItem As ContactItem
    Dim snpContacts As DAO.Recordset
    Dim intCurrRec As Integer, intRecCount As Integer

    Application.Echo True, "Initializing to create Outlook contacts. Please wait..."

    Set snpContacts = CurrentDb.OpenRecordset("tbl_board", dbOpenSnapshot)

    '-- Get the record count for the progress meter
    snpContacts.MoveLast
    intRecCount = snpContacts.RecordCount
    snpContacts.MoveFirst

    SysCmd acSysCmdInitMeter, "Creating Outlook contacts...", intRecCount
    intCurrRec = 1

    Set olkApp = CreateObject("Outlook.Application")
    Set olkNameSpace = olkApp.GetNamespace("MAPI")

    '-- Create an Outlook contact entry for each Calypso contact record
    Do Until snpContacts.EOF
    SysCmd acSysCmdUpdateMeter, intCurrRec

    Set objContactItem = olkApp.CreateItem(olContactItem)
    With objContactItem

    .FirstName = snpContacts!FirstName
    .LastName = snpContacts!LastName
    '.BusinessAddress = snpContacts!primAddress
    ' .BusinessAddressCity = snpContacts!City
    ' .BusinessAddressState = snpContacts!State
    ' .BusinessAddressPostalCode = snpContacts!Zip
    '.BusinessTelephoneNumber = snpContacts!PhoneHome

    '-- This helps to know this Outlook contact came from Access
    .Categories = "Access Contact"

    .Save

    End With
    snpContacts.MoveNext
    intCurrRec = intCurrRec + 1
    Loop

    Set objContactItem = Nothing
    Set olkNameSpace = Nothing
    Set olkApp = Nothing

    SysCmd acSysCmdClearStatus


    End Function

    Sub ap_ClearOLContacts()

    Dim objOLFolder As Outlook.MAPIFolder
    Dim olContactItem As ContactItem

    Application.Echo True, "Deleting Access Contacts in Outlook..."

    Set olkApp = New Outlook.Application
    Set olkNameSpace = olkApp.GetNamespace("MAPI")

    Dim intCurrContact As Integer

    Set objOLFolder = olkNameSpace.GetDefaultFolder(olFolderContacts)

    '-- Delete starting from the last of the list
    For intCurrContact = objOLFolder.Items.Count To 1 Step -1

    '-- Delete the entry if it came from Calypso
    If objOLFolder.Items(intCurrContact).Categories = "Access Contact" Then
    objOLFolder.Items.Remove (intCurrContact)
    End If

    Next

    Application.Echo True

    End Sub

  5. #5
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Copying Access records to Outlook (XP sp2)

    I'm afraid I've forgotten more DAO syntax than I ever learned. If you are reading every record shown on your progress bar, and the progress bar reflects all the records in the table, then I really have no idea why only some of the contacts are showing up.

    Does it work better/differently if you use dbOpenTable rather than dbOpenSnapshot?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •