Access.2007.VBA.Bibl..

(John Hannent) #1
NextSourceRecord1:
rstSource.MoveNext
Loop

rstSource.Close

Company phones and IDs are handled similarly; only one possible value (Company Phone) is syn-
chronized, because that is the only one that matches a field in Outlook:

Set rstSource = dbs.OpenRecordset(strQueryCompanyIDs, _
dbOpenDynaset)

Do While Not rstSource.EOF

Search for target record and update Company Phone field.

strTargetCustomerID = rstSource![CustomerID]
strSearch = “[CustomerID] = “ & Chr$(39) _
& strTargetCustomerID & Chr$(39)
‘Debug.Print “Search string: “ & strSearch
rstTarget.FindFirst strSearch
rstTarget.Edit
rstTarget![CompanyMainTelephoneNumber] = _
Nz(rstSource!CompanyMainTelephoneNumber)
rstTarget.Update

NextSourceRecord2:
rstSource.MoveNext
Loop

rstSource.Close

Finally, contact addresses are processed, using a query that converts each address field to the
appropriate Business, Home, or Other address field in the target table. Figure 11.11 shows one of
the calculated fields in this query.

Part II Writing VBA Code to Exchange Data between Office Components

Free download pdf