Results 1 to 4 of 4
  1. #1
    Mattbro is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Mar 2012
    Posts
    100

    Query criteria for field containing a character from another field in the same query

    Hello everyone. I have 2 tables-TblStaff and TblTraining.



    TblStaff has a field 'Category' which lists the training profile code for each staff member ('a' to 'g' depending on post).

    TblTraining lists each training element and has a field 'Category1' in which the relevent training profile codes are listed e.g. Element ABC1 may be relevant to staff groups 'a', 'e', and 'f', thus the Category1 Field for Element ABC1 would be 'aef'.

    I am trying to write a query that picks the Staff ID from a combo box and lists the Staff ID and Category from TblStaff with all relevent Training Elements for that member of staff from TblTraining. I have started with the following code
    Code:
    SELECT TblStaff.StaffID, TblStaff.Category, TblTraining.Element, TblTraining.SOP, TblTraining.Category1
    FROM TblStaff, TblTraining
    WHERE (((TblStaff.StaffID)=[Forms]![FrmTraining]![Combo1]) AND (((TblTraining.Category1) Like [TblStaff.Category]));
    'Like' only returns the value where TblTraining.Category is identical to TblStaff.category. Cant get '*'s and '"'s into the criteria field and I don't know where to start with the SQL for "any field in 'TblTraining.Category1' that contains the same letter as TblStaff.Category". If anyone could point me in the right direction, I would be grateful.
    Many thanks,
    Mattbro

  2. #2
    Mattbro is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Mar 2012
    Posts
    100
    Bah!
    Code:
    SELECT TblStaff.StaffID, TblStaff.Category, TblTraining.Code, TblTraining.Activity, TblTraining.SOP, TblTraining.Category1
    FROM TblStaff, TblTraining
    WHERE (((TblStaff.StaffID)=[Forms]![FrmPreC]![Combo1]) AND ((TblTraining.Category1) Like "*[TblStaff.Category]*"));

  3. #3
    Mattbro is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Mar 2012
    Posts
    100
    Hmm-doesn't work. Doesn't filter out the categorys that don't have the relevant letter in the TblStaff.Category. Any ideas?

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    I'm not following your description of the issue. A lot of times with situations involving

    -employees, their acquired training, the positions they occupy and the training requirements of the position-
    it is a table/data structure based issue.

    This diagram may help, but as I said, the post isn't clear (to me at least).

    Good luck.
    Attached Thumbnails Attached Thumbnails EmployeesAndPositions_V0.jpg  

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

Similar Threads

  1. Query with criteria without field from table
    By macattack03 in forum Queries
    Replies: 3
    Last Post: 11-03-2013, 05:54 PM
  2. Replies: 4
    Last Post: 02-08-2013, 11:35 PM
  3. Different criteria for same field in same query
    By teirrah1995 in forum Queries
    Replies: 10
    Last Post: 08-12-2011, 01:03 PM
  4. Query multiple field & criteria
    By fua in forum Access
    Replies: 2
    Last Post: 11-04-2009, 08:22 PM
  5. query - criteria based on another row field value
    By techexpressinc in forum Queries
    Replies: 1
    Last Post: 05-29-2009, 04:17 PM

Tags for this Thread

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