• AdvancedFind (VBA / Outlook / XP)

    Author
    Topic
    #405729

    I’m using the Advanced Search method to find emails with a string somewhere in the body of the email. It is working fine, except when the search term is something like “Jones and Jones” – the search string must get confused with the “and” and the LIKE business. Here is the string I pass to AdvancedSearch as the filter:
    strF = “urn:schemas:httpmail:subject LIKE ‘%” & vSearchTerm & “%’ or urn:schemas:httpmail:textdescription LIKE ‘%” & vSearchTerm© & “%'”
    It fails when vSearchTerm = “Jones and Jones”
    Should I somehow include quotes in the variable? Or enter them in the strF string?
    THANKS SO MUCH!

    Viewing 1 reply thread
    Author
    Replies
    • #835992

      Try single quotes in the mutliple word variable, such as

      vSearchTerm = ‘Jones and Jones’

      You might want to build the surrounding single quotes with Chr(39). Such as (air code):

      strUserEntry = InputBox(“Look for What? “, “Search Me!”)
      vSearchTerm = Chr(39) & strUserEntry & Chr(39)

      Post back if this doesn’t help.

      • #836255

        John
        Thanks for the tips. For some reason, it is now searching the string properly without having to add quotes.
        David

      • #836256

        John
        Thanks for the tips. For some reason, it is now searching the string properly without having to add quotes.
        David

    • #835993

      Try single quotes in the mutliple word variable, such as

      vSearchTerm = ‘Jones and Jones’

      You might want to build the surrounding single quotes with Chr(39). Such as (air code):

      strUserEntry = InputBox(“Look for What? “, “Search Me!”)
      vSearchTerm = Chr(39) & strUserEntry & Chr(39)

      Post back if this doesn’t help.

    Viewing 1 reply thread
    Reply To: AdvancedFind (VBA / Outlook / XP)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: