Results 1 to 4 of 4
  1. #1
    Steven Seagal is offline Novice
    Windows XP Access 2003
    Join Date
    Jun 2012
    Posts
    20

    Chained IIF statements in this query referring to a specific record. Help?

    I have a list of 200 employees, supervisors, and managers. Each has a job grade level A, B, C. I already have a table that acts as a key that lets you know which position gets which job grade.



    So the "key" would look like this [JobKey]:

    Position ---- Grade
    Employee ---- A
    Supervisor ---- B
    Manager ---- C

    Now in this list of 200+ employees, I already know the names and what position they are. I need to make a matrix with just employee names and their job grades.

    So I have a table that has this - let's call it [EmployeeList]

    Name Job
    Al --- Employee
    Bob --- Supervisor
    Carol --- Manager

    I want to create this kind of query:

    Al - A
    Bob - B
    Carol - C

    How would this be done in a query?

    I'm guessing 2 fields - 1 for Name from [EmployeeList] and the other field a chain of IIFs that look like this:

    iif( [EmployeeList.Position] = "Employee", [JobKey.Grade], iif( [EmployeeList.Position] = "Supervisor", [JobKey.Grade], iif( [EmployeeList.Position] = "Manager", [JobKey.Grade] )))

    However, where where it has [JobKey.Grade], it doesn't know what job grade to pick. I need it to pick a specific cell adjacent to the position in the job key title, but I have no idea how to do this. Any tips? Thanks

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    You shouldn't need a formula, nor do you want one. In your query, add the job key table and join the two tables on the related field.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Steven Seagal is offline Novice
    Windows XP Access 2003
    Join Date
    Jun 2012
    Posts
    20
    I've tried this but in reality, I have 25 different 'codes' (not just job grade) to fit in the same matrix. The example I gave about was just a dummy for ease of explanation. When trying to link these queries together, the program just froze. Also, I have these job key tables in queries. WOuld it speed things up if I used tables instead?

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    And you want to code 25 options into a formula? The normalized approach is having them in a table and joining the tables in a query. I don't understand what you mean by having them in a query not a table. Can you post the db here?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 1
    Last Post: 06-15-2012, 05:51 PM
  2. How to assign a specific value to each record within a query
    By Access2007_NewUser in forum Access
    Replies: 1
    Last Post: 04-22-2012, 08:28 PM
  3. Replies: 8
    Last Post: 01-13-2012, 08:20 AM
  4. Open form to a specific record from a query
    By chris.williams in forum Forms
    Replies: 11
    Last Post: 10-06-2011, 04:15 PM
  5. Replies: 2
    Last Post: 11-26-2010, 04:20 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