Results 1 to 8 of 8
  1. #1
    Anil Bagga is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Apr 2020
    Posts
    69

    Cascading Combo Boxes

    I created a table with Country, State and City . In the form I select country, state and then city. I am able to select the state easily after selecting country. Using the same logic, I am unable to select the city from the same table matching the value of state. I have gone through the data over last 2 / 3 days, created a new form but still having issues. The screenshots enclosed will explain my problem. I used the same logic for State and City but why City is not showing in drop down is a mystery

    Need HELP.
    Attached Files Attached Files

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    the query for combo3 (city) should look at city:
    select city from table where [state] = forms!fMyForm!cboState

    BUT everytime user picks a cboState, you must refresh cboCity:
    Code:
    sub cboState_Afterupdate()
      cboCity.requery
    end sub

  3. #3
    Anil Bagga is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Apr 2020
    Posts
    69
    Quote Originally Posted by Anil Bagga View Post
    I created a table with Country, State and City . In the form I select country, state and then city. I am able to select the state easily after selecting country. Using the same logic, I am unable to select the city from the same table matching the value of state. I have gone through the data over last 2 / 3 days, created a new form but still having issues. The screenshots enclosed will explain my problem. I used the same logic for State and City but why City is not showing in drop down is a mystery

    Need HELP.

    I have Requery in the configuration

    I think we need to look at ALL the Cities of states in the table where the states = cboState of the form. Therefore the code below seems to be correct. The code is copy pasted from the Row source file populated from query builder

    SELECT CountryStateMaster.[CustCity], CountryStateMaster.State FROM CountryStateMaster WHERE (((CountryStateMaster.State)=[Forms]![CustMasterFrm]![State]));

    I am unable to upload the database file due to size restrictions

  4. #4
    CarlettoFed is offline Competent Performer
    Windows 7 64bit Access 2013 32bit
    Join Date
    Dec 2019
    Posts
    273
    You must first compress it through a file compression program such as Winzip or Winrar.

  5. #5
    Anil Bagga is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Apr 2020
    Posts
    69
    Quote Originally Posted by Anil Bagga View Post
    I have Requery in the configuration

    I think we need to look at ALL the Cities of states in the table where the states = cboState of the form. Therefore the code below seems to be correct. The code is copy pasted from the Row source file populated from query builder

    SELECT CountryStateMaster.[CustCity], CountryStateMaster.State FROM CountryStateMaster WHERE (((CountryStateMaster.State)=[Forms]![CustMasterFrm]![State]));

    I am unable to upload the database file due to size restrictions

    I am enclosing the database file, after compressionCascadeComboTest.accdb.zip

  6. #6
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,610
    Change the Bound Column property of the "State" combo box from 3 to 1
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  7. #7
    Anil Bagga is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Apr 2020
    Posts
    69
    Perfect. Thanks. This worked!! What is the logic? Will appreciate an response for a better understanding. The "State" is in Column 0 and is showing either way!

  8. #8
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,610
    Quote Originally Posted by Anil Bagga View Post
    Perfect. Thanks. This worked!! What is the logic? Will appreciate an response for a better understanding. The "State" is in Column 0 and is showing either way!
    Technical explanations are not my strong point but as you've asked I'll do my best to explain my understanding. Other members might do it better. I'm sure you'll find lots with google.

    The bound column property dictates which piece of data is saved in the forms Record Source (Table/Query) in the field used as the controls Control Source property. With the Bound Column setting of "3" you were actually saving the "State Code" so the criteria used in the Row Source property of the "CusCity" combo was returning records where the state was the same as the State Code ("GJ" for example). Of course no records match so the "CusCity" combo was always empty.

    I hope this helps. Post back if you have further questions.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

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

Similar Threads

  1. Cascading Combo Boxes
    By ldnguyen531 in forum Forms
    Replies: 9
    Last Post: 07-12-2017, 05:03 PM
  2. cascading combo boxes
    By SunTop in forum Forms
    Replies: 18
    Last Post: 12-26-2016, 01:38 PM
  3. Cascading Combo Boxes
    By Heathey94 in forum Queries
    Replies: 26
    Last Post: 09-05-2016, 03:02 PM
  4. cascading Combo boxes
    By Chatholo in forum Forms
    Replies: 2
    Last Post: 08-09-2013, 01:39 AM
  5. Sum of Cascading Combo Boxes
    By alonewolf23 in forum Forms
    Replies: 2
    Last Post: 11-20-2011, 02:10 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