Search code examples
ms-access-2007

Flexible Like in access 2007


I have this code. But I can not get it anything.

       SMain_EW = RS.Fields("Main_EW").Value
       Dim MyCheck
       If SMain_EW Like "*" & Me.Text0 & "*" = True Then
           MsgBox "1"
       End If

Edited:******************** I edited as bellow:

        Do Until RS.EOF
           SMainEW = RS.Fields("Main_EW").Value
           ST_EW_1 = RS.Fields("T_EW_1").Value
           If SMainEW Like "*" & Me.Text0 & "*" Then
               strItem1 = "*" & RS.Fields("Main_EW").Value
               strItem2 = RS.Fields("T_EW_1").Value
           ElseIf ST_EW_1 Like "*" & Me.Text0 & "*" Then
               strItem2 = "*" & RS.Fields("T_EW_1").Value
               strItem1 = RS.Fields("Main_EW").Value
           Else
               strItem2 = RS.Fields("T_EW_1").Value
               strItem1 = RS.Fields("Main_EW").Value
           End If
            strItem = strItem1 & ";" _
            & strItem2
            Me.List122.AddItem strItem
           RS.MoveNext
        Loop

Solution

  • Try removing the "= True" portion, it's redundant. It should just read:

       SMain_EW = RS.Fields("Main_EW").Value
       Dim MyCheck
       If SMain_EW Like "*" & Me.Text0 & "*" Then
           MsgBox "1"
       End If