Sql Help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dstyles7
    New Member
    • Mar 2007
    • 8

    Sql Help

    I CREATED A LIST BOX AND TEXT BOX WITH A COMMAND BUTTON BELOW
    THE TXT BOX IS USED TO FIND INFO IN THE LIST BOX . I CREATED A SQL STAMENT THAT DOES THIS. HOWEVER I WOULD LIKE TO CREATE A WILD CARD WHERE IF SOMEONE ENTERS CARACTERS FROM A-Z IT WILL PULL UP A RECORD. BELOW IS MY CURRENT SQL STATEMENT


    SQL = "SELECT LWFieldKey, LWTableLink, LWTableName, [LWFieldName_4], [Field Description] " & _
    "FROM LWTABLES INNER JOIN LWFIELDS ON " & _
    "LWTABLES.LWTab leKey = LWFIELDS.LWTabl eLink " & _
    "WHERE [LWFieldName_4] = '" & txtlwField & "' OR " & _
    "[Field Description] = '" & txtlwDescriptio n & "'"
  • scripto
    New Member
    • Oct 2006
    • 143

    #2
    here you go

    SQL = "SELECT LWFieldKey, LWTableLink, LWTableName, [LWFieldName_4], [Field Description] " & _
    "FROM LWTABLES INNER JOIN LWFIELDS ON " & _
    "LWTABLES.LWTab leKey = LWFIELDS.LWTabl eLink " & _
    "WHERE [LWFieldName_4] like '%" & txtlwField & "%' OR " & _
    "[Field Description] like '%" & txtlwDescriptio n & "%'"

    Comment

    • dstyles7
      New Member
      • Mar 2007
      • 8

      #3
      It is still pulling up a error message

      Comment

      • scripto
        New Member
        • Oct 2006
        • 143

        #4
        Originally posted by dstyles7
        It is still pulling up a error message

        well what's the error message?

        Comment

        • dstyles7
          New Member
          • Mar 2007
          • 8

          #5
          Thanks for your help . i have i problem i can do a wild card search in txt field name and i pulls up the correct values however txt field description's wild card search isn't working. can you assist

          "WHERE [FFField Name] LIKE '*" & txtFieldName & "*' OR " & _
          "[Field Description]= '*" & txtDescription & "'"
          Set mRS = mDB.OpenRecords et(Sql, dbOpenSnapshot, dbFailOnError)

          Comment

          • scripto
            New Member
            • Oct 2006
            • 143

            #6
            "WHERE [FFField Name] LIKE '*" & txtFieldName & "*' OR " & _
            "[Field Description] LIKE '*" & txtDescription & "*'"
            Set mRS = mDB.OpenRecords et(Sql, dbOpenSnapshot, dbFailOnError)

            both fields should work the same way - unless you have an apostrophy (or any special chars) in your txtDescription field.

            Comment

            • dstyles7
              New Member
              • Mar 2007
              • 8

              #7
              Thanks again i changed it however when i try to to a wildcard search it goes directly to the first record in the list box no matter what name you type it goes to the first. unlike the othetr txt box where it finds and character that is entered in the list box.

              i really appreciate yur help


              "WHERE [FFField Name] LIKE '*" & txtFieldName & "*' OR " & _
              "[Field Description] LIKE '*" & txtDescription & "*'"
              Set mRS = mDB.OpenRecords et(Sql, dbOpenSnapshot, dbFailOnError)

              Comment

              Working...