Results 1 to 4 of 4
  1. #1
    billfold is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Apr 2012
    Posts
    2

    Multi-value Text Field Search

    First, I wanted to say hi, since this is my first post.

    Here is my issue. I am using just one table for this query, so it should be pretty straight forward, but I can't seem to return the results that I want. The query is based on Employee ID's and what departments they have associated with them. However, whoever designed the database made it a text field that could hold multiple values, and each value is comma delimited. Say I want to find all employee id's that are either associated to each department, or if an employee has access to multiple departments.

    So employee ID's 1, 2, 3
    Departments: a,b,c

    EmpID:1
    Departments: a

    EmpID: 2
    Departments: a,b

    EmpID: 3
    Departments: a,b,c,d,e,f

    Here is my most recent query. I know this isn't the answer, but I am at a loss here.

    SELECT
    EmpID, Departments
    FROM
    User
    WHERE Departments IN ('a','b','c'
    )



    Thank you

    Bill

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,601
    You need to determine if the field is a true multi-value (review https://www.accessforums.net/showthr...cus-on-Subform) or just a comma separated string in a text field.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    billfold is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Apr 2012
    Posts
    2
    It's just a comma seperated text field, not a true multivalue field.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,601
    Then the value is a single continuous string of 'a, b, c', not separate values of 'a', 'b', 'c'. This isn't going to work.

    You could use LIKE operator for cases such as: 'a, b, c, d' LIKE '*a, b*' or InStr("a, b, c, d", "a, b")

    But 'a, b, c' will not match against '*a, c*' and InStr("a, b, c", "a, c") will return 0.

    Will need VBA function code to parse and compare the string parts then return a True or False value to base criteria on.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Multi Field Combo search Form
    By Andyjones in forum Access
    Replies: 3
    Last Post: 03-12-2012, 02:13 PM
  2. Multi select search
    By simba in forum Access
    Replies: 2
    Last Post: 08-22-2011, 08:28 AM
  3. Replies: 6
    Last Post: 04-07-2011, 12:33 PM
  4. 2 multi select list boxes on one search form
    By woodey2002 in forum Forms
    Replies: 2
    Last Post: 11-05-2010, 12:44 PM
  5. How to Search a Text Field in Access
    By cnbhold in forum Access
    Replies: 1
    Last Post: 01-11-2010, 05:56 PM

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