Results 1 to 9 of 9
  1. #1
    ArnieT is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Dec 2017
    Posts
    10

    How to limit items in a pick list by a criterion in another field

    I want to build a database for people's names.


    The fields are these:
    First name
    Middle name
    Last name
    DOB
    State of birth
    County of birth
    City of birth

    The problem is with the last three items.I want to make a pick list for the state, county, and the city. No problem with the state. Just created a table with one text field and filled it up with states. Here is the Constructor view of the table.

    Click image for larger version. 

Name:	tblStates.jpg 
Views:	15 
Size:	25.6 KB 
ID:	32751

    Then I created a table for state counties. Here is its Constructor view.

    Click image for larger version. 

Name:	tblCounties.jpg 
Views:	14 
Size:	73.2 KB 
ID:	32752


    Here, the county field is a simple text type, but the state field is of the lookup type.
    The reason for this is that when entering a county in the table, I want to pick up its state from the list of states in the combo box (the states in it being sourced from the tblStates table) as is shown here:

    Click image for larger version. 

Name:	county_state.jpg 
Views:	14 
Size:	71.4 KB 
ID:	32753



    As a result, my table tblStates ended up looking like this:

    Click image for larger version. 

Name:	state_counties.jpg 
Views:	14 
Size:	61.8 KB 
ID:	32754


    That's not a problem, and I would say it's even a plus. I haven't figured out yet the way this relation works, though.
    But it's not important as far as my problem is concerned. At least, I don't think it is.The problem starts with the people's table. Here is what it looks like:

    Click image for larger version. 

Name:	people_state_county.jpg 
Views:	14 
Size:	69.3 KB 
ID:	32755



    To be exact, all counties for all states are available for picking, instead of only counties for the selected state, which is Alabama in this case.
    The constructor view for the birthCounty field of this table is this:
    (The forum won't let attach more than 5 images, so I am including the rest as URLs)

    https://my.pcloud.com/publink/show?c...eQCizJwj3yYzvy


    The birthState field type is also of the lookup type from the tblStates table. It works without any problems, as this table has no connected tables.

    So, my question is, how can I get only the counties for the selected state to show in the pick list for the birthCounty field?

    (Here, I included both columns in the pickup list for demonstration purposes only, so as to make it easier to see that counties for all states are in the pick list.)

    I believe there is a solution to this problem. I think I did a similar project long time ago (about 15 years ago), and I was able to filter out the pick list, limiting it only to the criteria in another field. At least I think I did. But it was so long ago that now I don't remember how I did it.

    And here is what my tblPeople table winded up looking like:

    https://my.pcloud.com/publink/show?c...xinryp5uURAgTy



    And here are the final relationships:


    https://my.pcloud.com/publink/show?c...E8onT5zBtVIozX


    Funny, there is no relationship between the tblStates table and the tblCounties table, even though in the latter I am picking states from the former.

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,850

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,646
    What you describe is known as cascading or dependent combobox. Must use a form with some coding. Common topic. Search forum or web. MS even offers a template db to demonstrate. I found it in: File>New>Calculator
    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.

  4. #4
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,706
    Here's something:
    People-v1.zip
    Demonstrates how to use comboboxes to select and show your data on a form, while actually storing the Foreign keys in the tables. Standard practice for lookups.
    After selecting a state, only counties in that state show in the county dropdown.
    Last edited by davegri; 02-25-2018 at 10:03 PM.

  5. #5
    ArnieT is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Dec 2017
    Posts
    10
    Deleted it. Duplicate. Don't know how to delete altogether.

  6. #6
    ArnieT is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Dec 2017
    Posts
    10
    Quote Originally Posted by June7 View Post
    What you describe is known as cascading or dependent combobox. Must use a form with some coding. Common topic. Search forum or web. MS even offers a template db to demonstrate. I found it in: File>New>Calculator
    Yes, looks like forms is the way to go. I was already pointed in that direction in another topic.
    Thank you for seconding this.

    P.S. As for searching the web and the forum, it's like digging for diamonds in diamond pits - one has to shovel over tens of tons of dirt just to find a carat of diamond. I was hoping for a fast solution here

  7. #7
    ArnieT is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Dec 2017
    Posts
    10
    Quote Originally Posted by June7 View Post
    I found it in: File>New>Calculator
    Thank you for shoving me in the right direction. This looks like exactly what I need.

    But I am still wandering if there is a way of doing this with tables. Because, actually, I wanted to create the DB in MySQL, but because of my meager knowledge of that DB decided to practice first in ACCESS. But, as far as I know, MySQL does not offer a crutch in the form of forms. So, how would this problem be approached in MySQL?

    But this is just a rhetorical question, because for the time being I will stick with ACCESS and hopefully, buy the time I know how to build the database I need in Access, I will know enough to build it in MySQL too.

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,646
    No, cannot be done in tables, of any db platform.

    Must use another application as interface.

    Access is one of many that can connect to MySQL tables and serve as user interface.
    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.

  9. #9
    ArnieT is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Dec 2017
    Posts
    10
    Quote Originally Posted by June7 View Post
    No, cannot be done in tables, of any db platform.

    Must use another application as interface.

    Access is one of many that can connect to MySQL tables and serve as user interface.

    I see. Thank you. I really appreciate your help on this matter.

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

Similar Threads

  1. Replies: 6
    Last Post: 12-03-2017, 02:23 PM
  2. Combo box limit to list doesnt limit
    By mcmcd99 in forum Access
    Replies: 6
    Last Post: 11-09-2017, 07:31 PM
  3. Replies: 15
    Last Post: 10-05-2017, 12:18 PM
  4. FYI: User pick list example
    By ranman256 in forum Tutorials
    Replies: 1
    Last Post: 09-01-2016, 06:09 AM
  5. Replies: 1
    Last Post: 02-03-2011, 11:19 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