locked
Wildcard in temp variable? RRS feed

  • Question

  • Good day, all-

    I'm trying to set a wildcard in a temp variable, but am having problems with the syntax.

    Currently, I've got:
        TempVars.Add "tempYear", "Like "" * """

    However, the query that this gets applied to returns with no results.

    Monday, January 25, 2016 2:40 PM

Answers

  • Currently, I've got:
        TempVars.Add "tempYear", "Like "" * """

    However, the query that this gets applied to returns with no results.

    Hi Casey,

    Now your TempVar has the VALUE:  "Like "" * """, and it is understandable that you get no resuls.

    In your sql-string you need somethimg like:

           " ... WHERE MyField Like ""*" & Tempvar & "*"""

    or    " ... WHERE MyField Like '*" & Tempvar & "*'" 

    Imb.

    Monday, January 25, 2016 3:33 PM

All replies

  • Currently, I've got:
        TempVars.Add "tempYear", "Like "" * """

    However, the query that this gets applied to returns with no results.

    Hi Casey,

    Now your TempVar has the VALUE:  "Like "" * """, and it is understandable that you get no resuls.

    In your sql-string you need somethimg like:

           " ... WHERE MyField Like ""*" & Tempvar & "*"""

    or    " ... WHERE MyField Like '*" & Tempvar & "*'" 

    Imb.

    Monday, January 25, 2016 3:33 PM
  • Hi Casey,

    The likely reason why you're getting no result is because the TempVar is being treated by the query engine as a String rather than an operator. In other words, the "Like" operator must be part of the query and not of the TempVar - just like how Imb showed it above.

    Just my 2 cents...

    Monday, January 25, 2016 3:46 PM