Access.2007.VBA.Bibl..

(John Hannent) #1
strSearch = “[ContactID] = “ & lngContactID _
& “ And [AddressType] = “ & Chr$(39) _
& strAddressType & Chr$(39)
Debug.Print “Search string: “ & strSearch
rstTarget.FindFirst strSearch
If rstTarget.NoMatch = True Then

Create a new contact address record in the target table.


rstTarget.AddNew
rstTarget![ContactID] = lngContactID
rstTarget![AddressType] = strAddressType
Else
rstTarget.Edit
End If

rstTarget![StreetAddress] = _
Nz(rstSource!OtherAddressStreet)
rstTarget![POBox] = _
Nz(rstSource!OtherAddressPostOfficeBox)
rstTarget![City] = _
Nz(rstSource!OtherAddressCity)
rstTarget![StateOrProvince] = _
Nz(rstSource!OtherAddressState)
rstTarget![PostalCode] = _
Nz(rstSource!OtherAddressPostalCode)
rstTarget![Country] = _
Nz(rstSource!OtherAddressCountry)
rstTarget.Update
End If

rstTarget.Close

UpdateCompanyPhone:

If there is a value in the Company Phone record in the source database, it is written to a record in
the target table (this is the only company phone number or ID that can be matched with Outlook,
so it is the only one that is synchronized). If none is found, a new record is created and updated
with the Company Phone number:


strTarget = “tblCompanyIDsPhones”
Set rstTarget = dbs.OpenRecordset(strTarget, _
dbOpenDynaset)
strDescription = “Company Phone”
strSearch = “[CompanyID] = “ & lngCompanyID _
& “ And [Description] = “ & Chr$(39) _
& strDescription & Chr$(39)
Debug.Print “Search string: “ & strSearch
rstTarget.FindFirst strSearch
If rstTarget.NoMatch = True Then

Synchronizing Access and Outlook Contacts 11

Free download pdf