Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2006
    Location
    Louisville, KY
    Posts
    2

    Filtering using a Substring Help

    Hello All



    I have been to the moon and back trying to figurer this one out; I have a form, with an Option group that a user can use to filter their data. Upon using a case statement the code looks like this

    Case 1
    strFilterSQL = strSQL & " Where [Device Name] = 'PE';"
    Case 2
    strFilterSQL = strSQL & " Where [Device Name] = 'CS';"

    This works however the returned values is a record that has the [Device Name] value of ONLY PE value. I want it to return all records that begin with the letters PE. Similiar to a "LIKE" statement in SQL, but i keep getting errors in VB when i type things like : LIKE [Device Name] = 'PE%' ??????????

    HTH

    Thanks

  2. #2
    StepUP is offline Advanced Beginner
    Windows 7 64bit Access 2000
    Join Date
    Dec 2005
    Posts
    99
    Instead of LIKE [Device Name] = 'PE%'

    Try

    Where [Device Name] Like 'PE*'

  3. #3
    Join Date
    Jan 2006
    Location
    Louisville, KY
    Posts
    2
    Thanks a Million, I got it to work, actually for some reason my Access liked the % wildcard instead of the *, anyways the syntax was the same as what you suggested, I wasnt getting any output with the * as the wildcard, but thought I would try it with % and it worked.

    Case 1
    strFilterSQL = strSQL & " Where [Device Name] Like 'PE%';"
    Case 2
    strFilterSQL = strSQL & " Where [Device Name] Like 'CS%';"

    Oh wel IT WORKS! Thanks

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Filtering my report
    By ldarley in forum Reports
    Replies: 1
    Last Post: 09-05-2008, 09:14 AM
  2. Replies: 0
    Last Post: 08-17-2008, 12:19 PM
  3. Automatic Filtering when Opening form
    By Karyn-2000 in forum Forms
    Replies: 1
    Last Post: 12-03-2005, 09:29 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums - Senior Forums