Results 1 to 4 of 4
  1. #1
    tomclavil is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Feb 2011
    Posts
    6

    Subquery

    Hello,



    I have a table with the following fields NAME1, NAME2, NAME3. The names comes from another table with a list of names so I have a drop down list with all the names for each field. I use certain parameters to reduce the names from the main list.

    What I need is that when I choose (assign) a name for the field NAME1, that choosen name does not appears in the drop down list for the fields NAME2 or NAME3.

    I imagine a subquery can be the solution, but I have no idea how to set it

    I would appreciate your help!
    Regards

    Tom

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,818
    Why do you have 3 similar name fields? This is an indicator of non-normalized data.

    So names chosen in Name1 and Name2 should not be available for Name3?
    Last edited by June7; 02-27-2012 at 03:06 AM.
    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
    tomclavil is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Feb 2011
    Posts
    6
    The reason for having 3 similar fields is that there is a task that needs to be performed by 3 different persons at the same time in the same place. If NAME1 was completed with "JOSEPH" and "JOSEPH" continues as part of the list, I can mistakenly use it again for the remaining 2 fields (NAME2 and NAME3) and in the real life, I will have only 1 person completing a task that needs to be completed by 3 different persons. Hopes this clarifies the situation.

    Thanks!

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,818
    I understood until the real life part, lost me there.

    Are you doing this lookup in table or form? I never build lookups in tables and I can't get this to work in table anyway. Do this in a form.

    Try this for RowSource in each combobox:

    SELECT ID, LastName & ", " & FirstName As EmpName FROM tablename WHERE ID <> Nz(combo2, 0) AND ID <> Nz(combo3, 0)
    SELECT ID, LastName & ", " & FirstName As EmpName FROM tablename WHERE ID <> Nz(combo1, 0) AND ID <> Nz(combo3, 0)
    SELECT ID, LastName & ", " & FirstName As EmpName FROM tablename WHERE ID <> Nz(combo1, 0) AND ID <> Nz(combo2, 0)

    Then will need code in AfterUpdate event of each combobox to requery the other two.
    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. TOP subquery
    By helpaccess in forum Queries
    Replies: 5
    Last Post: 08-30-2011, 10:28 AM
  2. Query with maybe subquery
    By AndycompanyZ in forum Queries
    Replies: 4
    Last Post: 06-28-2011, 11:45 AM
  3. Subquery sum?
    By anemoskkk in forum Access
    Replies: 0
    Last Post: 04-29-2011, 12:36 PM
  4. SQL SubQuery Does Not Work
    By saascuba in forum Access
    Replies: 3
    Last Post: 11-04-2010, 01:59 PM
  5. Subquery
    By combine21 in forum Queries
    Replies: 2
    Last Post: 09-17-2010, 04:33 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