Single quotes in filter string, how to manage????

  • Thread starter Wendi Taranto via OfficeKB.com
  • Start date
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 & "'")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top