Access.2007.VBA.Bibl..

(John Hannent) #1
FIGURE 11.11

A calculated query field that converts StreetAddress to BusinessAddressStreet.


The rstSource recordset is then selected, based on a query that selects contact addresses; the code looks
for a matching target record, and if it is found, it is updated with information from the recordset:

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

Do While Not rstSource.EOF
strTargetCustomerID = rstSource![CustomerID]
strSearch = “[CustomerID] = “ & Chr$(39) _
& strTargetCustomerID & Chr$(39)
‘Debug.Print “Search string: “ & strSearch
rstTarget.FindFirst strSearch
rstTarget.Edit
rstTarget![BusinessAddressStreet] = _
Nz(rstSource!BusinessAddressStreet)
rstTarget![BusinessAddressPostOfficeBox] = _
Nz(rstSource!BusinessAddressPostOfficeBox)
rstTarget![BusinessAddressCity] = _
Nz(rstSource!BusinessAddressCity)
rstTarget![BusinessAddressState] = _
Nz(rstSource!BusinessAddressState)
rstTarget![BusinessAddressPostalCode] = _
Nz(rstSource!BusinessAddressPostalCode)
rstTarget![BusinessAddressCountry] = _
Nz(rstSource!BusinessAddressCountry)

Synchronizing Access and Outlook Contacts 11

Free download pdf