Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    DAWNY2007 is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Nov 2021
    Posts
    35

    Limiting lists based on prior field selection

    Ok. I am a little rusty with Access and I have been wracking my brain on this one. I have created a form, where I am trying to have the user select STATE...then based on STATE selected, I want to limit the list to the Counties in that state. Based on that combination, I want the limited list of Zip Codes for each State / County. I have created 3 tables and tried to create a query linked by ID....However, there are duplicate values on state (due to multiple counties / zip codes). My head hurts...any ideas ?

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    the query for combo cboCounty is based on cboState
    qsCounties: select [county] from tCounties where [State]=forms!fMyForm!cboState

    and only code you need is to refresh cboCounty when user changes cboState:
    Code:
    sub cboState_afterupdate
    cboCounty.requery
    end sub

  3. #3
    DAWNY2007 is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Nov 2021
    Posts
    35
    So it would have to be written in code ? I can't have drop-downs in the form that get limited based on the State , then County selections ?

  4. #4
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,791
    You need code for cascading combos to work. Each time you pick a parent value the child combos have to be requeried, using the parent combo value as the criteria for the child combo list. They don't do this on their own.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,563
    Can you upload your database?
    You can PM me if you need further help.
    Good Reading https://docs.microsoft.com/en-gb/off...on-description

  6. #6
    DAWNY2007 is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Nov 2021
    Posts
    35
    I tried to attach a dummy version of it (proprietary information), but no matter what I do, the database is too large to attach.

  7. #7
    DAWNY2007 is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Nov 2021
    Posts
    35

    Managed to Zip the file.

    There is limited data (excluding the state / county / zip tables, as this us proprietary information
    Attached Files Attached Files

  8. #8
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,563
    Hi

    You will need to step back a bit , stop what your are doing and read up on Normalisation of Tables.

    None of your tables have an Autonumber as the Primary Key. Each table should have an Autonumber.

    You are using Lookup fields in tables. This is a No - No in Access

    Your fieldnames should NOT have any Spaces or any characters other than A through to Z

    You should set Referential Integrity between related tables.
    You can PM me if you need further help.
    Good Reading https://docs.microsoft.com/en-gb/off...on-description

  9. #9
    DAWNY2007 is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Nov 2021
    Posts
    35
    Thank you. I will look into this. I do have 3 tables with autonumbers. I should probably save the look-ups for the form design and remove from the table itself. Users will only be touching the form. As I said, I am a bit rusty ! Thanks so much. I will start from the beginning :-)

  10. #10
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,406
    You can do all that from one table.

    Click image for larger version. 

Name:	zips.png 
Views:	15 
Size:	7.0 KB 
ID:	46676

    Here's example DB:

    Dawny-davegri-v01.zip

  11. #11
    DAWNY2007 is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Nov 2021
    Posts
    35
    Thanks for this, however, the users will not know the zip code. So, I am looking for zip code to automatically populate based on the state / county combination. Note that I am aware that there are several zip codes per county, but for our purposes, we are limiting to one per county, as we just need general area. Thanks !

  12. #12
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,406
    Quote Originally Posted by DAWNY2007 View Post
    Thanks for this, however, the users will not know the zip code. So, I am looking for zip code to automatically populate based on the state / county combination. Note that I am aware that there are several zip codes per county, but for our purposes, we are limiting to one per county, as we just need general area. Thanks !
    OK easy enough. Changed combo to text box. Text box shows a random zipcode in the state/county.

    Click image for larger version. 

Name:	zip2.png 
Views:	16 
Size:	5.0 KB 
ID:	46678

    DB: Dawny-davegri-v02.zip

  13. #13
    DAWNY2007 is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Nov 2021
    Posts
    35
    Thank you !!!!

  14. #14
    DAWNY2007 is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Nov 2021
    Posts
    35
    In looking at this now, this is great for a simple look-up. However, for my needs, I need the data for State / County and Zip to be stored in the table for each record. I am assuming that I can select a control source. I'm going to play with this a bit.

  15. #15
    DAWNY2007 is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Nov 2021
    Posts
    35
    I'll admit that I copied and modified this to match my table / field names. And I think I got the control source thing figured out. However, if you see attached, I am getting an error after selecting STATE / COUNTY. Getting closer !
    Attached Files Attached Files

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 02-16-2017, 12:54 PM
  2. Replies: 4
    Last Post: 05-02-2014, 02:08 PM
  3. Replies: 1
    Last Post: 06-17-2013, 11:44 AM
  4. Replies: 1
    Last Post: 08-02-2011, 06:23 AM
  5. Replies: 4
    Last Post: 07-28-2010, 10:27 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