Results 1 to 12 of 12
  1. #1
    qwerty is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Oct 2018
    Posts
    91

    Creating a combo box that interacts with a list box


    The goal is following,

    1. Pick 1 of 2 regions in the combo box.
    2. The list box then displays the cities in those regions, and you can only select one city.
    3. Then submit takes you to a new page or form based on the selected criterias.

  2. #2
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,941
    this is called cascading combo's. Plenty about them on this and other forums. In principle

    rowsource to combo (called say cboAreas)

    SELECT RegionPK, RegionName FROM tblRegions

    rowsource to listbox (called say lstCities)

    SELECT CityPK, CityName FROM tblCities


    in the lstCities Enter Event put

    lstCities.Rowsource="SELECT CityPK, CityName FROM tblCities WHERE RegionFK=[cboAreas]"


    in the lstCities Exit Event put

    lstCities.Rowsource="SELECT CityPK, CityName FROM tblCities"

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    the combo box has 2 columns: caption, Query
    the combo is bound to col 2, but col 2 has width =0 so user only sees the caption

    the afterupdate event:
    lstCities.rowsource = cboBox

  4. #4
    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,870
    Last edited by orange; 11-01-2018 at 05:37 AM.

  5. #5
    qwerty is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Oct 2018
    Posts
    91
    Thank you all for your continued support. I got some of the feature8s setup, except for the button.

    1. I have 2 combobox and 1 listbox.
    2. Combo1 has west and east. (Region tbl)
    3. Combo2 displays the location either for west or east. (States tbl)
    4. Listbox displays the sublocations. (Cities tbl)

    How do I write the code for the button after selecting the sublocation to move on to the next page, so the data stays consistent with the selected city?

    In my relationship after the cities table there are two species table as well. Not sure if this should be part of the button as well.
    Last edited by qwerty; 11-01-2018 at 09:30 AM.

  6. #6
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,941
    you need to provide more detail and be clearer about what you are asking for

    best guess at the moment is to use

    docmd.OpenForm "formname",,,"CityID=" & CityID

    No idea what the relevance of species is. But the normal rule is one form, one table, so sounds like these tables, if required, should be in subforms on the form you are opening.

  7. #7
    qwerty is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Oct 2018
    Posts
    91
    Quote Originally Posted by Ajax View Post
    you need to provide more detail and be clearer about what you are asking for

    best guess at the moment is to use

    docmd.OpenForm "formname",,,"CityID=" & CityID

    No idea what the relevance of species is. But the normal rule is one form, one table, so sounds like these tables, if required, should be in subforms on the form you are opening.

    asking for help with creating a button that takes you to a new page.

  8. #8
    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,870
    asking for help with creating a button that takes you to a new page

    Does this mean go to a new record?

    Ajax has provided
    docmd.OpenForm "formname",,,"CityID=" & CityID

    which would open "formname" with criteria to restrict records to a specific CityID.

    Please provide a sample to put your question in to context. What does new page mean to you in terms of a Form?

  9. #9
    qwerty is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Oct 2018
    Posts
    91
    Quote Originally Posted by orange View Post
    asking for help with creating a button that takes you to a new page

    Does this mean go to a new record?

    Ajax has provided
    docmd.OpenForm "formname",,,"CityID=" & CityID

    which would open "formname" with criteria to restrict records to a specific CityID.

    Please provide a sample to put your question in to context. What does new page mean to you in terms of a Form?
    For example, signing up for an email account. On the first form you enter certain information, and click next to go to the next page. The button remembers the information in first page to continue with the new page. The new page will have additional information and options you need to select. The last third page be about the client. Depending were they live the selected data in page 1 will correspond with that city. For information about that species in Iowa if that is what you selected on page 1.

  10. #10
    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,870
    Further to Ajax's comment in post #6
    No idea what the relevance of species is. But the normal rule is one form, one table, so sounds like these tables, if required, should be in subforms on the form you are opening
    , can you overview the scope of your project so readers understand your posts/questions/responses in context.

    When you are dealing with form(s) and subforms, they are usually called "form". We/I do not see how regions, cities, species and signing up for an email account "fit together". All we are asking for is the 30,000 ft overview that relates these pieces.

  11. #11
    qwerty is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Oct 2018
    Posts
    91
    Quote Originally Posted by orange View Post
    Further to Ajax's comment in post #6
    , can you overview the scope of your project so readers understand your posts/questions/responses in context.

    When you are dealing with form(s) and subforms, they are usually called "form". We/I do not see how regions, cities, species and signing up for an email account "fit together". All we are asking for is the 30,000 ft overview that relates these pieces.
    Maybe like how a car website operates, when building a new car.

    You select make, model, and trim. Then it you click next and gives you other options to choose from on the new page. Based on the criteria you selected on the first page.

    Page 1, you select the region, location, and sublocation. This filters the data out to only that location. There more information that needs to be filled or selected on page 2. Page 2 will be related to filling out information about the species based on the location selected from 1.

    It's a input form and selection option, for example you select the iowa from the first page. Then you select blue bird in page 2, it's only going to provide data about the blue birds in Iowa.

    I have created the combo and list box. They work perfectly together, how do I create the button so that it is dependent based on the selections made in the list box?

  12. #12
    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,870
    ???I am using email as an example.???
    How about plain English, real life example.

    Consider a database of bird sightings in various areas across North America. What set up would allow a user to access specific species by region (country,area,state/prov,city)?
    It is important to work with your expected outputs (responses to anticipated user requests).

    For example:

    What is the most popular species sighted in Utah? in Mexico? In Canadian Prairies?
    What are the top X in Iowa? In Alaska? West of the Mississippi?
    Are Cardinals ever sighted in New Brunswick? In Hawaii?
    What raptors are found in Canada, but not in Mexico?

    So how should you define/design region in order to answer the above?

    Loading/inputting data may require several forms/subforms.
    Accessing/reading data may only require 1 form with several combo boxes.

    Good luck with your project.

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

Similar Threads

  1. Replies: 3
    Last Post: 06-16-2018, 11:12 PM
  2. Replies: 2
    Last Post: 03-07-2018, 11:00 PM
  3. Replies: 2
    Last Post: 03-23-2017, 01:16 PM
  4. Replies: 7
    Last Post: 03-07-2017, 03:01 PM
  5. Replies: 4
    Last Post: 10-21-2013, 11:06 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