Results 1 to 3 of 3
  1. #1
    Vitto82 is offline Novice
    Windows XP Access 2003
    Join Date
    Jun 2012
    Posts
    2

    Question two drop-down list in a query

    Hi Everybody!!,

    first of all, thanks for all your support and help.

    IŽll try to explain my situation:

    I have a table T1 with 2 fields "NAME" and "TEAM"

    NAME TEAM


    JOHN ----- YANKEES
    MARK ----- RED SOXS
    PAUL ----- GIANTS
    JOHN ----- GIANTS
    STEVE ----- RED SOXS
    MARK ----- YANKEES

    I create a query using parameters, named C1
    in his criteria "=[NAME]"
    that's make it will appear a pop-up box, where I can introduce a name to filter this query. For example, "JOHN", it would return JOHN -- YANKEES and JOHN GIANTS.

    If I want to replace this pop-up box, with a drop-down list box, I need to create a FORM, called F1, with a simple combobox, and create a button with the event code DoCmd.OpenQuery "C1" .

    in the query's design properties, in his criteria I wrote forms!F1!C1 and it works!!

    But, my question is about to use this system with 2 drop-down list.

    I mean, make a query, filtering with "JOHN" and "YANKEES" ... but using a drop-down list, not writing in the SQL-sentence the criteria.

    I want just to do the filtering using NAME and TEAM, and sadly, it doesn't work !!

    Anybody knows how to do that?

    thanks so much for your attention and your support.

    PS: I want apologize for my english if I do so much grammar mistakes. greetings from Barcelona!

  2. #2
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,849
    The concept you are dealing with is called Cascading Comboboxes.
    When you select an entry from the first combo, you want to display values in the second combo that meet the criteria for combo 1.

    If your first combo is for [Name] and you choose "John", you want the second to show [TEAM] (where name = "John")

    There are free video tutorials at
    http://www.datapigtechnologies.com/f...combobox1.html and
    http://www.datapigtechnologies.com/f...combobox2.html

  3. #3
    Vitto82 is offline Novice
    Windows XP Access 2003
    Join Date
    Jun 2012
    Posts
    2

    Smile query

    Quote Originally Posted by orange View Post
    The concept you are dealing with is called Cascading Comboboxes.
    When you select an entry from the first combo, you want to display values in the second combo that meet the criteria for combo 1.

    If your first combo is for [Name] and you choose "John", you want the second to show [TEAM] (where name = "John")

    There are free video tutorials at
    http://www.datapigtechnologies.com/f...combobox1.html and
    http://www.datapigtechnologies.com/f...combobox2.html
    Thanks for you answer, orange. This is not exactly my situation. I don't need to do a "cascading Comboboxes", because it means using forms. In my situation I need a "cascading comboboxes" in a query. I mean is not introducing values with a form.

    in a cascading comboboxes with a form, I choose one of the names JOHN, MARK, PAUL, etc... and after this, I choose one of the teams... YANKEES, RED SOXS, GIANTS... etc...
    Using an appropiate example for this cascading comboboxes, is for states and locations, If I choose NORTH, I can't choose in the second combo the STATE of CALIFORNIA, because the relation between STATE and LOCATION, I only have available the STATES at NORTH. ( thats perfect solution for this case, but is not mine!! )

    my real situation, is that I make a Query, for example, imagine the next table REGISTER.

    NAME ----- AGE -----TEAM
    JOHN ----- 25 ----- YANKEES
    MARK ----- 18 ----- RED SOXS
    PAUL ----- 31 ----- GIANTS
    JOHN ----- 22 ----- GIANTS
    STEVE ----- 19 ----- RED SOXS
    MARK ----- 22 ----- YANKEES

    I would make a query using parameters. If I want this, I'll write in the query's design options =[AGE] in the column AGE, row Criteria. That makes appear a pop-up dialog box, where I need to write the AGE, I want to filter. in this case, its suppose I wrote "22". Then, the query returns

    JOHN ----- 22 ----- GIANTS
    MARK ----- 22 ----- YANKEES

    now, i try to change this pop-up box, with a drop-down list ( I'll do that, and it works!!! ), so when I execute the QUERY, the query execute a form too, in this form, I put a combobox, with the drop-down list, and I choose the AGE ( 25,18, 31, 22, 19 ), in my case, 22. And I put a button, in the same form, with the instruction of executing the QUERY with the parameter "22".

    This part is done and it works perfectly. ( with a little bit of a VBA : DoCmd.OpenQuery "nameofQuery" in the button's properties and forms!nameform!namecombobox in the criteria row, column age.)

    But now, I want to do that, with 2 parameters. I mean, execute the query... ( important, is a query, not a form... ), after this, the query open a form, with 2 drop-down list , like AGE and TEAM. In this case, I choose AGE "22", and when I choose TEAM, It doesn't matter if my options doesn't have any relation. I mean, If I choose AGE "22", when I choose TEAM, I wanna see ALL OPTIONS ( GIANTS, YANKEES, and RED SOXS ).
    Of course I know that any register match with "22-RED SOX" , but is not a problem, I want this result "0".
    After choose 22 and GIANTS, I push the button, that execute the real query and only returns :

    JOHN ----- 22 ----- GIANTS


    I only have words to be grateful for your help and patience. Hope anyone knows how to do that.

    PS: The words in capital letters absolutely not mean shouting or screaming, thanks for all!!!

    greetings from Barcelona!

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

Similar Threads

  1. Drop Down List
    By haazzaa in forum Forms
    Replies: 3
    Last Post: 03-19-2012, 05:17 PM
  2. How to get key for drop-down list
    By mitchmcc in forum Access
    Replies: 2
    Last Post: 11-29-2011, 06:21 AM
  3. drop down list
    By slimjen in forum Access
    Replies: 6
    Last Post: 09-15-2011, 01:43 PM
  4. Replies: 4
    Last Post: 06-16-2011, 09:30 PM
  5. drop down list
    By tceicher in forum Access
    Replies: 5
    Last Post: 08-13-2009, 05:41 AM

Tags for this Thread

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