Results 1 to 3 of 3
  1. #1
    MrRuz is offline Novice
    Windows 8 Access 2013
    Join Date
    Jan 2013
    Posts
    10

    Lookup query on own table

    Hi guys!



    I'm trying to run a query in a lookup attribute that references the table that it's in while maintaining data integrity. The problem I'm having is restricting the lookup to records that match the current record.

    For example, in Table 1 (tbl_Category) below, I can query Level1 of Category2 to only show Category as an option by using the SQL

    Code:
    SELECT tbl_Category.Level2, tbl_Category.Name
    FROM tbl_Category
    WHERE (((tbl_Category.Level1) Is Not Null))
    ORDER BY tbl_Category.CategoryName;
    My problem is I'd like to restrict the selections of all records in Level1 and Level2 to records where Type is equal to the Type of the current record. So, For example, in Table 2, Category 3 in Level 1 would only be allowed to select Category 3 or Category 4 because their types are equal.

    I would of course, use this same method in Level2.


    Table 1: tbl_Category
    ID Type Name Level1 Level2
    1 1 Category null null
    2 1 Category2 Category
    3 2 Category3 null


    Table 2: tbl_Category
    ID Type Name Level1 Level2
    1 1 Category null null
    2 1 Category2 Category
    3 2 Category3 null
    4 2 Category4 Category3

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Sounds like cascading comboboxes. Review http://www.datapigtechnologies.com/f...combobox2.html
    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
    MrRuz is offline Novice
    Windows 8 Access 2013
    Join Date
    Jan 2013
    Posts
    10
    Hey thanks! I'll look at it when I get home.

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

Similar Threads

  1. Replies: 11
    Last Post: 01-15-2014, 02:02 PM
  2. update query using a lookup table
    By slimjen in forum Queries
    Replies: 2
    Last Post: 04-27-2012, 03:46 PM
  3. Query to lookup relative field from table selection
    By shabbaranks in forum Queries
    Replies: 5
    Last Post: 12-20-2011, 11:12 AM
  4. Lookup name in a query on a non-joined table
    By karmacable in forum Queries
    Replies: 7
    Last Post: 09-21-2011, 09:01 AM
  5. Date Lookup in Query for Junction Table
    By Phasma in forum Access
    Replies: 2
    Last Post: 01-21-2011, 03:36 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