Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / December 2006

Tip: Looking for answers? Try searching our database.

importing from outlook problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Russ - 29 Nov 2006 13:33 GMT
When importing outlook information into my contacts and companies table
Getting error Error 3022; The changes you requested to the table were not
successful because they would create duplicate values in the index, primary
key, or relationship. (Error 3022) You tried to duplicate a value in a field
that is the underlying table's primary key or an index that does not allow
duplicates. The message includes the following instruction: Change the data
in the field or fields that contain duplicate data, remove the index, or
redefine the index to permit duplicate entries, and try again.

How can I verify company name does not exsit in the tblContactCompanies table,
and if it does use that information instead of duplicating it? Any help would
be great! Thanks in advance...

Private Sub cmdImportFromOutlook_Click()
     
  ' Set up DAO objects
  Dim rst As DAO.Recordset
  'Query qryContactWithCompanies uses existing "tblContacts" &
"tblContactCompanies" table
  'SELECT tblContacts.*, tblContactCompanies.CompanyName
  'FROM tblContactCompanies INNER JOIN tblContacts ON tblContactCompanies.
CompanyID = tblContacts.CompanyID;
  'Note CompanyNname field in tblContactCompanies is indexed (No Duplicates)
  Set rst = CurrentDb.OpenRecordset("qryContactWithCompanies")

  ' Set up Outlook objects.
  Dim ol As New Outlook.Application
  Dim olns As Outlook.NameSpace
  Dim cf As Outlook.MAPIFolder
  Dim C As Outlook.ContactItem
  Dim objItems As Outlook.Items
  Dim Prop As Outlook.UserProperty
  Dim iNumContacts As Integer
  Dim I As Variant
 
  Set olns = ol.GetNamespace("MAPI")
  Set cf = olns.GetDefaultFolder(olFolderContacts)
  Set objItems = cf.Items
  iNumContacts = objItems.Count
  If iNumContacts <> 0 Then
     For I = 1 To iNumContacts
        If TypeName(objItems(I)) = "ContactItem" Then
           Set C = objItems(I)
           rst.AddNew
           rst!ContactTypeID = 1
           rst!NameTitle = IIf(Len(C.Title & "") > 0, C.Title, "") '(mr., ms,
mrs....)
           rst!FirstName = IIf(Len(C.FirstName & "") > 0, C.FirstName,
"Unknown")
           rst!CompanyName = IIf(Len(C.CompanyName & "") > 0, C.CompanyName,
Me.LastName & " " & "Family")
            rst.Update
        End If
     Next I
     rst.Close
     Set rst = Nothing
     MsgBox "Finished, Contacts were successfully imported."
     Form.Requery
  Else
       'Something went wrong, couldn't initialize Outlook
       MsgBox "An error occured while importing data."
  End If

End Sub
Russ - 01 Dec 2006 20:06 GMT
Can anyone help?

>When importing outlook information into my contacts and companies table
>Getting error Error 3022; The changes you requested to the table were not
[quoted text clipped - 60 lines]
>
>End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.