Results 1 to 10 of 10
  1. #1
    Join Date
    Jul 2002
    Posts
    8

    Unanswered: combo boxes dependent on other combo boxes

    Hi,

    I have 2 combo boxes. The first combo box is a category of a query. The second combo box is the relevant types of queries for that category.

    I have two tables: QryTypeGroups and QryType. The field "groupID" is referenced in both. In QryType there is a long list of types of queries. Now depending upon which category has been selected in 1st combo, i want to only populate the 2nd combo with the relevant query types.

    How do i do this?

    thanks.

    fennis

  2. #2
    Join Date
    Oct 2002
    Location
    Greensboro, NC
    Posts
    50

    Re: combo boxes dependent on other combo boxes

    Originally posted by awesomefennis
    Hi,

    I have 2 combo boxes. The first combo box is a category of a query. The second combo box is the relevant types of queries for that category.

    I have two tables: QryTypeGroups and QryType. The field "groupID" is referenced in both. In QryType there is a long list of types of queries. Now depending upon which category has been selected in 1st combo, i want to only populate the 2nd combo with the relevant query types.

    How do i do this?

    thanks.

    fennis
    Hi fennis,

    in the properties of qrytype the recordsource criteria will have forms!formname!combo1. make sure that your bound column in the first combo box is groupid. when you select from combo 1 only the querytypes that are associated with the groupid will populate the second combo box. also in the after update property of combo 1. you need to requery combo box 2.

    tina

  3. #3
    Join Date
    Jul 2002
    Posts
    8

    further problems

    Hi,

    Thanks for your help so far. However, I have run in to further problems now

    I have got it working so that when you select a value from the 1st combo it then limits the selection of the 2nd combo. However, this little application is for multiple records. When I switch to another record, and change the 1st combo for that record, it then loses the value for the original 2nd combo box. Does that make sense? Basically, Due to the fact that I am limiting the record source on the "on change" event for the 1st combo, whenever I change it, it affects all records.

    Here is a step to step example of what I am doing.

    Record 1:
    Combo 1 set to "Meetings"
    Combo 2 is now limited
    Combo 2 set to "Monday"

    GOTO Record 2:
    Combo 1 set to "Holidays"
    Combo2 is now limited
    Combo 2 set to "Tuesday"

    NOW...When I go back to Record 1 - it has lost the value "Monday".

    Hope someone can help me ASAP....thanks!

    Fennis

  4. #4
    Join Date
    Oct 2002
    Location
    Greensboro, NC
    Posts
    50

    Re: further problems

    Originally posted by awesomefennis
    Hi,

    Thanks for your help so far. However, I have run in to further problems now

    I have got it working so that when you select a value from the 1st combo it then limits the selection of the 2nd combo. However, this little application is for multiple records. When I switch to another record, and change the 1st combo for that record, it then loses the value for the original 2nd combo box. Does that make sense? Basically, Due to the fact that I am limiting the record source on the "on change" event for the 1st combo, whenever I change it, it affects all records.

    Here is a step to step example of what I am doing.

    Record 1:
    Combo 1 set to "Meetings"
    Combo 2 is now limited
    Combo 2 set to "Monday"

    GOTO Record 2:
    Combo 1 set to "Holidays"
    Combo2 is now limited
    Combo 2 set to "Tuesday"

    NOW...When I go back to Record 1 - it has lost the value "Monday".

    Hope someone can help me ASAP....thanks!

    Fennis
    Hi Fennis,

    You need to set your control source of your combo boxes.

    tina

  5. #5
    Join Date
    Mar 2002
    Location
    London, UK
    Posts
    22
    tina,

    Both my combo boxes have a control source already set

    Any other ideas?

    fennis

  6. #6
    Join Date
    Oct 2002
    Location
    Greensboro, NC
    Posts
    50
    Originally posted by ecynaxt
    tina,

    Both my combo boxes have a control source already set

    Any other ideas?

    fennis
    hi fennis,

    can you send me a sample of your database. right off the top of my head I can't think of what the problem could be without actually looking at your database.

    tina

  7. #7
    Join Date
    Oct 2002
    Location
    Greensboro, NC
    Posts
    50
    Originally posted by ecynaxt
    tina,

    Both my combo boxes have a control source already set

    Any other ideas?

    fennis
    what are the control sources for your combo boxes?

  8. #8
    Join Date
    Jul 2002
    Posts
    8
    here is the access database....

    thanks for your help
    Attached Files Attached Files

  9. #9
    Join Date
    Aug 2003
    Posts
    48
    I have this exact same problem!!!

    Rather than start a new post on the subject, could either of you guys already on this post thread/someone else with knowledge of this problem please tell me how to overcome it.

    It's basically that in order to refresh the values in the 2nd combo box when you update the value in the first one, you have to use a requery, unfortunately, when you navigate to the other records or refresh the form in any way, it triggers the requery and wipes the value from the form (but the value does still remain stored on the table). Is there a way to call up the value from the table 'on the fly'? (I already have Controlsource configured correctly and this alone doesn't do it).


    Cheers for any advice on this!!!

    Luke

  10. #10
    Join Date
    Aug 2003
    Posts
    48
    Right folks!!!

    It is the SqlStr line that is the problem, specifically the following snippet of code:

    Code:
    WHERE (((tblOBJECTIVES.OwnerID)=forms!frmCREATEREPORT!cboOwnerID))
    Because this code filters the Slave combo box to values available only from the CURRENTLY selected Master combo box field, when I navigate to other records with different primary combo box fields selected, their slave combo box values cannot be displayed.

    Therefore, the only 2 ways I can think of to correct this is either to somehow limit this filter to the CURRENT record in question, or to just remove the code (but this will allow the user to select ALL the slave combo box values instead of those exclusive the the selected field in the master combo box, and defeats the object).

    Here is the complete code:

    Code:
    Private Sub cboOwnerID_AfterUpdate()
    Dim SqlStr As String
    
         SqlStr = "SELECT tblOBJECTIVES.ObjID, tblOBJECTIVES.Objective
    FROM tblOBJECTIVES
    WHERE (((tblOBJECTIVES.OwnerID)=forms!frmCREATEREPORT!cboOwnerID))
    ORDER BY tblOBJECTIVES.ObjID;"
    
    Me!cboObjID.Enabled = True
    Me!cboObjID.RowSource = SqlStr
    Me!cboObjID.Requery
    I'd be REALLY grateful if someone could give me some advise on how to deal with this!!

    I know what the problem is, I just don't know how to fix it!!

    Cheers,

    Luke
    Last edited by Lukasx; 10-09-03 at 09:34.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •