How to use like command in code behind page to compare with recordset value ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Chandan Kr Sah
    New Member
    • Aug 2010
    • 11

    How to use like command in code behind page to compare with recordset value ?

    How to use like command in code behind page to compare with recordset value ?

    As I want to do comparision like below

    Code:
    Dim rs As DAO.Recordset
    If rs1![Activity].Value Not Like & '*Prep*'" Then
    '...do calculations
    End If
    But this will not work.
    So please can tell me how I can do that type of comparisions.

    Thanks
    Chandan Kr Sah
  • Mariostg
    Contributor
    • Sep 2010
    • 332

    #2
    Try:
    If inStr(rs1![Activity].Value,'Prep')= 0 Then


    From the Help file:

    InStr Function Example
    This example uses the InStr function to return the position of the first occurrence of one string within another.

    Dim SearchString, SearchChar, MyPos
    SearchString ="XXpXXpXXPX XP" ' String to search in.
    SearchChar = "P" ' Search for "P".

    ' A textual comparison starting at position 4. Returns 6.
    MyPos = Instr(4, SearchString, SearchChar, 1)

    ' A binary comparison starting at position 1. Returns 9.
    MyPos = Instr(1, SearchString, SearchChar, 0)

    ' Comparison is binary by default (last argument is omitted).
    MyPos = Instr(SearchStr ing, SearchChar) ' Returns 9.

    MyPos = Instr(1, SearchString, "W") ' Returns 0.

    Comment

    Working...