Access.2007.VBA.Bibl..

(John Hannent) #1
If Nz(rstSource![BusinessFaxNumber]) <> “” Then
strDescription = “Business Fax”
strSearch = “[ContactID] = “ & lngContactID _
& “ And [Description] = “ & Chr$(39) _
& strDescription & Chr$(39)
Debug.Print “Search string: “ & strSearch
rstTarget.FindFirst strSearch
If rstTarget.NoMatch = True Then

Create a new contact ID record in the target table.


rstTarget.AddNew
rstTarget![ContactID] = lngContactID
rstTarget![Description] = strDescription
Else
rstTarget.Edit
End If

rstTarget![IDOrPhone] = _
Nz(rstSource![BusinessFaxNumber])
rstTarget.Update
End If

[I am not listing a great number of similar code segments, each of which updates a different phone
number or ID.]


If Nz(rstSource![PersonalHomePage]) <> “” Then
strDescription = “Web Page”
strSearch = “[ContactID] = “ & lngContactID _
& “ And [Description] = “ & Chr$(39) _
& strDescription & Chr$(39)
Debug.Print “Search string: “ & strSearch
rstTarget.FindFirst strSearch
If rstTarget.NoMatch = True Then

Create a new contact ID record in the target table.


rstTarget.AddNew
rstTarget![ContactID] = lngContactID
rstTarget![Description] = strDescription
Else
rstTarget.Edit
End If

rstTarget![IDOrPhone] = _
Nz(rstSource![PersonalHomePage])
rstTarget.Update
End If

NextSourceRecord:
rstSource.MoveNext

Synchronizing Access and Outlook Contacts 11

Free download pdf