Results 1 to 4 of 4
  1. #1
    K Roger is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Sep 2011
    Posts
    27

    Combo Boxes with dependent queries

    I have an Access form which has 3 combo boxes where the results of the 1st one determines the contents of the 2nd drop down box and the 3rd box choices are determined by the results of the 1st and 2nd queries.

    Specifically, the first box is a list of states, the 2nd a list of counties and the 3rd a list of townships or other MCD's.

    There are 50 states, 3150 county names, and 35,700+ names's involved.
    The 1st box contains the states. Then a "SELECT DISTINCTROW" narrows the counties down to a number found in the particular state chosen, The 3rd box then has a "SELECT DISTINCT ROW" that further narrows the choices of MCD's dependent upon the results of the 1st two combo box choices.

    Currently the queried file is flat containing all three desired fields.

    Specifically:

    The 1st box is a straight forward combo box picking 1 of 50 states

    The 2nd box Row/Source code used is: SELECT distinctrow [qryCo].[countyname] FROM qryCo where [qryco].[state] = [forms]![frmLiatrisAllCondensed]![statex] order by [qryCo].[countyname];

    The 3rd box Row/Source code used is: SELECT distinctrow [qryTwp].[MCD],[qryTwp].[countyname],[qrytwp].[state] FROM qrytwp where [qrytwp].[state] = [forms]![frmLiatrisAllCondensed]![statex] AND [forms]![frmLiatrisAllCondensed]![county1] = [qrytwp].[countyname] order by [qrytwp].[countyname], [qrytwp].[mcd];

    The problem is:
    The code works for the first time a choice is made.



    However thereafter, the 2nd and 3rd boxes do not change and remain the values for the first state picked during the session.
    The only workaround with the current code I have found is to exit the form and reenter then it - a very impractical situation.

    What am I not doing code-wise or not doing at all.

    Any help would be appreciated. I am familiar with using ACCESS but only moderately familiar writing my own VB code

    BTW - I would eventually like to normalize the file (break it into 3 files) because of other data needed that is unique to one of the three files.

    Thank you K Roger

  2. #2
    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,726
    BTW - I would eventually like to normalize the file (break it into 3 files) because of other data needed that is unique to one of the three files.
    It is important to normalize your database now... not later.
    Getting the structures correct will simplify many tasks.

    See the first few topics at this site for normal forms, normalization and Entity relationship diagramming
    http://www.rogersaccesslibrary.com/forum/topic238.html

    As for cascading combos, watch this free video tutorial.
    http://www.datapigtechnologies.com/f...combobox2.html

  3. #3
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    In addition to the links provided by Orange, here is one more that is helpful to understand cascading combo boxes.

    http://www.fontstuff.com/access/acctut10.htm

    I agree with Orange about Normalization. Do it first and it will avoid issues later.

    Alan

  4. #4
    K Roger is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Sep 2011
    Posts
    27
    Thanks to the 2 respondents that assisted me with the problem.

    The requeries on updates helped the situation but did not totally resolve the issue. I added a requery to the combo boxes within a "got focus" event and that seemed to resolve the non-changing values completely. Is there some reason that a "got focus" event should not be used as a requery action other than the possible redundancy and overhead involved with this action?

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

Similar Threads

  1. Dependent Combo box issue
    By pratim09 in forum Forms
    Replies: 9
    Last Post: 08-30-2011, 01:01 AM
  2. Year Dependent on Combo Box
    By hawkins in forum Access
    Replies: 7
    Last Post: 08-12-2011, 04:15 PM
  3. Dependent List Boxes do not refresh using ReQuery
    By weeblesue in forum Programming
    Replies: 2
    Last Post: 03-28-2011, 08:47 AM
  4. Dependent Combo Box
    By tigers in forum Forms
    Replies: 1
    Last Post: 06-16-2009, 12:46 PM
  5. Replies: 3
    Last Post: 02-26-2009, 10:17 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