W
Wendi Taranto via OfficeKB.com
I want to filter Contact Items. If any of the values in the filter string
contain a single quote, there is parse error. How do you manage this type
of data and perform a successful filter?
My code follows:
strLast = "0'Brien"
strFirst = "Jeff"
strAddress = "401 Heavens Lane"
strCity = "Detroit"
strState = "MI"
strZip = "87633"
Dim objContactFolder As Outlook.MAPIFolder
Dim objFilteredItems As Outlook.Items
Dim objContactItems As Outlook.Items
Dim i As Integer
Dim objContactItem As Outlook.ContactItem
Set objContactFolder = objMAPI.GetDefaultFolder(10)
Set objContactItems = objContactFolder.Items
objContactItems.Sort "[LastModificationTime]", True
Set objFilteredItems = objContactItems.Restrict("[LastName] = '" &
strLast & "' And [FirstName] = '" & strFirst & "' And
[BusinessAddressStreet] = '" & strAddress & "' And [BusinessAddressCity] =
'" & strCity & "' And [BusinessAddressState] = '" & strState & "' And
[BusinessAddressPostalCode] = '" & strZip & "'")
contain a single quote, there is parse error. How do you manage this type
of data and perform a successful filter?
My code follows:
strLast = "0'Brien"
strFirst = "Jeff"
strAddress = "401 Heavens Lane"
strCity = "Detroit"
strState = "MI"
strZip = "87633"
Dim objContactFolder As Outlook.MAPIFolder
Dim objFilteredItems As Outlook.Items
Dim objContactItems As Outlook.Items
Dim i As Integer
Dim objContactItem As Outlook.ContactItem
Set objContactFolder = objMAPI.GetDefaultFolder(10)
Set objContactItems = objContactFolder.Items
objContactItems.Sort "[LastModificationTime]", True
Set objFilteredItems = objContactItems.Restrict("[LastName] = '" &
strLast & "' And [FirstName] = '" & strFirst & "' And
[BusinessAddressStreet] = '" & strAddress & "' And [BusinessAddressCity] =
'" & strCity & "' And [BusinessAddressState] = '" & strState & "' And
[BusinessAddressPostalCode] = '" & strZip & "'")