Results 1 to 7 of 7
  1. #1
    BSJoJaMAx4's Avatar
    BSJoJaMAx4 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2015
    Posts
    48

    Use data in one combo box to populate other

    Hi all



    I have a table (named locations) as follows:

    Building Room
    Building A Smith
    Building B Yarra
    Building A Grand
    Building A Elite
    Building C Small
    I want the user to select the building first from a combo box, but then only allow the user to select the rooms relating to the building (ie select A and get Smith, Grand, Elite) from a combo box.

    In building combo box in row source I have
    Code:
    SELECT DISTINCT locations.Building FROM locations;
    which works (unless I need to change for the room combo box query).
    Code I have issue with is for the room.
    In Room combo box in row source I have
    Code:
    SELECT locations.room FROM locations WHERE locations.building = building ORDER BY locations.room;
    Thanks in advance

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    Is this what you're looking for?

    http://www.baldyweb.com/CascadingCombo.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    BSJoJaMAx4's Avatar
    BSJoJaMAx4 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2015
    Posts
    48
    Thanks Paul - exactly what I am after. I have had a look at the sample and tried to adapt it to my file. Its kind of working but not pulling the room only data for the sites.

    Table is called bay with building (text) and bay (text)

    For the building combo I have as follows:

    Control Source: BuildingNew
    Name: buildingcheck
    Row Source:
    Code:
    SELECT bay.building FROM bay GROUP BY bay.building;
    in after update
    Code:
    Private Sub BuildingNew_AfterUpdate()    Me.Bay = vbNullString
        Me.Bay.Requery
    End Sub
    For the room data

    Control Source: Bay
    Name: Bayconfirmation
    Row Source:
    Code:
    SELECT Bay.Bay FROM Bay WHERE (((bay.building)=Forms![Parking Bookings]!Buildingnew)) ORDER BY [bay].[bay];

  4. #4
    BSJoJaMAx4's Avatar
    BSJoJaMAx4 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2015
    Posts
    48
    Actually, on second inspection it appears to be working. What I was doing was selecting a building, then going to the room (which works first time). When I try to select another building it still displays the rooms from the other building. How do I reset it each time?

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    The requery should update the selections. It doesn't look like you're using the name of the combo in the requery though. Change to that and see how it works.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    BSJoJaMAx4's Avatar
    BSJoJaMAx4 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2015
    Posts
    48
    Thanks Paul - I dont understand what i did but fixing that up did the trick. Appreciate the help.

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    No problem.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 2
    Last Post: 01-06-2014, 04:22 PM
  2. Replies: 6
    Last Post: 05-16-2013, 07:44 PM
  3. Replies: 2
    Last Post: 01-08-2013, 08:49 AM
  4. Replies: 2
    Last Post: 12-05-2012, 10:17 AM
  5. Replies: 6
    Last Post: 04-27-2012, 01:31 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