Results 1 to 8 of 8

Thread: [RESOLVED] ADODC Recordset.Find - Single Character Wildcard

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Dec 2006
    Location
    Toronto, Canada
    Posts
    19

    Resolved [RESOLVED] ADODC Recordset.Find - Single Character Wildcard

    Sorry to be a bother again, but nowhere can I find
    what the ADODC single-character wildcard is for the Find method.
    Help says underscore (_) but it doesn't work for me.
    e.g.:
    Adodc1.Recordset.Find "Tag LIKE 'ab_d'"

    *** Answer: ADODC doesn't support single character wildcards ***

    Underscore works if it's run in an SQL statement:
    e.g.
    SQL="SELECT * FROM Table1 WHERE Title LIKE 'ab_d'"
    Adodc1.RecordSource = SQL
    Adodc1.Refresh

    I could just use SQL, but I'm not sure what SQL statement
    to use to do a Find within an existing record set. I can't use
    a SELECT because the user may have changed a record that
    would disappear with a new SELECT.

    *** Answer: Unanswered ***

    Also can't determine how to deal with finds where
    the % and _ characters may be part of the search
    pattern; e.g.: .Find "filename LIKE 'file_001.txt'" or
    "Result LIKE '50%'". The backslash (\) Escape character
    doesn't work as it does with MySQL.

    *** Answer: Square brace literals - LIKE '50[%]' gets 50% and not 50lb ***
    Last edited by jm1248; Jan 15th, 2007 at 08:23 AM. Reason: Summarize

  2. #2
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: ADODC Recordset.Find - Single Character Wildcard

    The ADO Recordset Find and Filter methods do not support single character wildcards.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Dec 2006
    Location
    Toronto, Canada
    Posts
    19

    Re: ADODC Recordset.Find - Single Character Wildcard

    Thanks Bruce,

    Did they used to? The VB6 ADO Help suggests it did.
    Anyway, I'm going to use a programatic find instead.

    Re the Escape question: Can you tell me what the ADO
    expects in the SQL string to denote a literal character?

    " .. can't determine how to deal with finds where
    the % and _ characters may be part of the search
    pattern; e.g.: .Find "filename LIKE 'file_001.txt'" or
    "Result LIKE '50%'". The backslash (\) Escape character
    doesn't work as it does with MySQL."

    Thanks,
    John

    PS: Your Canucks really abused my Leafs last night!

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: ADODC Recordset.Find - Single Character Wildcard

    When using like you can specify valid characters for a position by placing them in square brackets (eg: [0123456789] to allow a number), so you should be able to simply place the character on its own inside square brackets. (From memory, I haven't checked!)

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Dec 2006
    Location
    Toronto, Canada
    Posts
    19

    Re: ADODC Recordset.Find - Single Character Wildcard

    Quote Originally Posted by si_the_geek
    When using like you can specify valid characters for a position by placing them in square brackets (eg: [0123456789] to allow a number), so you should be able to simply place the character on its own inside square brackets. (From memory, I haven't checked!)
    So 50[%] should get 50% and not 50lb?

  6. #6
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: ADODC Recordset.Find - Single Character Wildcard

    Correct... but I'm not sure if it accepts wildcards in that manner, so it may not return 50%

  7. #7
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: ADODC Recordset.Find - Single Character Wildcard

    So 50[%] should get 50% and not 50lb?
    No. Find and Filter only support "Starts With" and "Contains" wildcard searches. Ie 'A%' and/or '%A%'.

  8. #8

    Thread Starter
    Junior Member
    Join Date
    Dec 2006
    Location
    Toronto, Canada
    Posts
    19

    Re: ADODC Recordset.Find - Single Character Wildcard

    Thanks guys,

    I'm using SQL statements for user searches with []'s to escape literals. Works fine.
    I now only use ADODC.Find to reposition the recordset to its unique ID.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width