Results 1 to 6 of 6
  1. #1
    apchampa is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Aug 2015
    Posts
    6

    Linking Tables to a Field Dynamically based on the value of another field

    Here is my issue...



    I have a field, let's call it "Item Type", and it is linked to a table called "List-Item Type" which contains the values that you can select for this field.

    Now, depending on what item you select I want another field, let's call it "Item Sub Type", to link to specific tables associated with each Item Type.

    For Example........ If an individual selects "Computer" from the Item Type list then I want the Sub Type field to link to the "List-Computer Types" table which then will contain something like Laptop, Desktop, Server, etc.

    But, if an individual selects "Mobile Phone" from the Item Type list then I want the Sub Type field to link to a completely different table called "List-Phone Types" which will have values like Smartphone, etc.

    I hope I'm making sense. I'm assuming the only way to do this is some sort of script........ but it would be super cool if Access had a built-in way to quickly do it.

    Thanks for your time.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,969
    Requires VBA to change the combobox RowSource SQL statement.

    Or use a UNION query that merges info from all of the 'Type' tables as one dataset to serve as source for combobox RowSource.

    Why are the types in different tables? Are the fields really so different?
    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
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    What you are describing sounds like a composite key. When you have one record and it takes two fields combined to create a unique key, that is a composite key. I use code to manage referential integrity and constraints for tables with composite keys.

  4. #4
    apchampa is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Aug 2015
    Posts
    6
    I wanted to keep things in different tables so that the user only sees specific choices and they can't accidentally choose something I don't want them to...... I could use one big list but then they would have to hunt & peck to find what they want, maybe not find the best match and select something different, etc. Easier to only put in front of the user a limited set of choices.

  5. #5
    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,743
    apchampa,

    Do yourself a favor and work through this tutorial on database and table design. You will learn how to design your tables and relationships based on your business requirements. Tables don't get selected/created arbitrarily or by magic, they are based on your business needs. Spend 45-60 minutes on the tutorial --the best use of your time at this point.

    For a broader overview see this link

    More info on Normalization




  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,969
    Conventional approach would be 1 table then manage what users are presented with by filtering. Review http://datapigtechnologies.com/flash...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.

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

Similar Threads

  1. Query that sums a field based on 2 tables
    By scratchmb in forum Queries
    Replies: 6
    Last Post: 03-18-2012, 08:31 PM
  2. Create tables based on field value
    By fpmsi in forum Programming
    Replies: 5
    Last Post: 11-17-2011, 12:42 PM
  3. Changing tables based on field date
    By dssrun in forum Programming
    Replies: 6
    Last Post: 07-10-2011, 10:17 AM
  4. Replies: 6
    Last Post: 06-08-2011, 05:00 PM
  5. lost - linking date field based on a record with smaller Unique ID
    By stan.chernov@gmail.com in forum Queries
    Replies: 7
    Last Post: 09-16-2010, 02:22 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