Results 1 to 5 of 5
  1. #1
    Kennyej is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jul 2015
    Posts
    4

    Casc combo box from 1 table

    Can anyone point me towards a how to that shows how to create cascading combo boxes in a form where the combo box values are all pulled from the same table? Or tell me if it's just not possible?

    Thanks,


    Evan

  2. #2
    ranman256's Avatar
    ranman256 is online now VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    Not really enough info, but usu,...
    say cboState is picked NY.
    to fill the cboCity box, in the cboState AFTERUPDATE event.
    cboCity.requery

    the query feeding the cboCity uses cboState in the criteria.
    select City from TCities where state = forms!frmForm!cboState

    the AFTERUPDATE code refreshes the list.

  3. #3
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,849

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,632
    Continuing ranman's example. Table of cities with fields for CityName, StateCode (and/or StateName).

    State combobox:
    SELECT DISTINCT StateCode FROM Cities ORDER BY StateCode;

    City combobox:
    SELECT CityName FROM Cities WHERE StateCode = [cboState] ORDER BY CityName;

    Then code to requery the city combobox:
    Me.cboCity.Requery

    Code would go in cboState AfterUpdate or cboCity GotFocus events.
    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.

  5. #5
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Quote Originally Posted by Kennyej View Post

    Can anyone point me towards a how to that shows how to create cascading combo boxes in a form where the combo box values are all pulled from the same table? Or tell me if it's just not possible?
    orange has given you a couple of links with videos, the second one being specifically about cascading comboboxes, and June7 has given a succinct explanation on how it is done, but FYI, it not only is possible for the values in cascading comboboxes to come from the same table...they usually, by the very nature of the beast, come from the same table!

    Linq ;0)>

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

Similar Threads

  1. Replies: 2
    Last Post: 10-10-2014, 05:33 AM
  2. Combo Box not populating table
    By Chatholo in forum Forms
    Replies: 2
    Last Post: 08-27-2013, 10:33 PM
  3. Replies: 25
    Last Post: 03-19-2013, 10:08 PM
  4. Table Combo Box
    By buienxg in forum SQL Server
    Replies: 1
    Last Post: 11-24-2011, 11:27 AM
  5. Replies: 1
    Last Post: 08-13-2011, 12:03 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