I'm missing something: Dependent queries

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mbedford
    New Member
    • May 2010
    • 23

    I'm missing something: Dependent queries

    qryKeyEmployeeK ey
    based on control in form:
    Code:
    SELECT UID
    FROM listEmployeeKey
    WHERE KeyID=Forms!formKey!txtKeyID;
    Very simple. It returns a column of values based on who I've assigned keys to. It works.

    When I don't have the form open, it asks for the value of Forms!formKey!t xtKeyID, and when I give it that value manually, it returns the list of associated UIDs.

    qryKeyEmployee
    based on qryKeyEmployeeK ey.UID:
    Code:
    SELECT *
    FROM tblEmployee
    WHERE tblEmployee.UID=qryKeyEmployeeKey.UID;
    I assume that running this query should return a list of the employee information associated to the UIDs listed in qryKeyEmployeeK ey. Or, if formKey is closed, it should ask for the value of Forms!formKey!t xtKeyID prior to display the appropriate data.

    However, instead it always asks for the value of qryKeyEmployeeK ey, which leads me to believe that reference is incorrect.

    I've checked the spelling of the query dozens of times and verified the name of the field UID is correct in all locations.

    What am I missing?
  • Oralloy
    Recognized Expert Contributor
    • Jun 2010
    • 988

    #2
    Well, equality implies a single value. I think you want to use the relationship "IN".

    Try this:
    Code:
    SELECT * 
    FROM tblEmployee 
    WHERE tblEmployee.UID IN qryKeyEmployeeKey.UID;
    Or, maybe more specifically:
    Code:
    SELECT * 
    FROM tblEmployee 
    WHERE tblEmployee.UID IN
      (SELECT SELECT UID 
        FROM listEmployeeKey 
        WHERE KeyID=Forms!formKey!txtKeyID)

    Comment

    Working...