Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    raychow22 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    May 2017
    Posts
    145

    Cascading Combo Boxes

    Hello Forum,

    I am having trouble with the cascading combo boxes.

    I want to display "Segment" combo box that list Segments 1-4. Each Segment has its own "Work Area". WA 1,2,3,& 4. After the first selected "Segment" box is selected; The next "Work Area" box will be specific to the "Segment" selected.

    I have tried some tutorials, but was unsuccessful.


    Click image for larger version. 

Name:	Cascade2.png 
Views:	18 
Size:	21.3 KB 
ID:	29032
    Attached Thumbnails Attached Thumbnails Cascade1.png   Cascade 3.png   Cascade 4.png  

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    the query for cboWorkArea, looks at cboSegment....

    select WAID from table where segment = forms!myForm!cboSegment

    BUT you need to refresh the cbo after the pick so the list refreshes:

    Code:
    sub cboSegment_afterupdate()
       cboWorkArea.requery
    end sub

  3. #3
    raychow22 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    May 2017
    Posts
    145
    ranman256,

    Thanks for the reply!! So I tried selecting WAID table where segment = forms!myform!cboSegment. It shows up blank. Here are the pictures to illustrate.

    Click image for larger version. 

Name:	Cascade 5.png 
Views:	15 
Size:	17.6 KB 
ID:	29036


    Click image for larger version. 

Name:	casade 6.png 
Views:	15 
Size:	18.4 KB 
ID:	29037

    Click image for larger version. 

Name:	cascade 7.png 
Views:	15 
Size:	24.8 KB 
ID:	29038

  4. #4
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    First, it looks like your table contains lookups - remove them, they mess up what you are trying to accomplish.

    Second, fix your naming conventions, it is all too confusing. Change all primary key fields to what it contains, e.g. SegmentID, and use that name on all other tables. Change fields to have more descriptive names, e.g. SegmentName. When designing a table, you are a techy, not a user, so use names that are absolute where there is no doubt as to what the field contains. Much of your confusion comes from this.

    tblWAID contains a field called "Segments" - with a name like this who knows what it contains. Your screenshot shows that it is storing the SegmentID (correctly). After you have changed the name of this field, go back to your work area row source query. The criteria says "this segment ID must match the segment ID which is in the first column of the combobox Segment" - which hopefully is the SegmentID.

  5. #5
    raychow22 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    May 2017
    Posts
    145

    Cascading Combo Boxes

    Quote Originally Posted by aytee111 View Post
    First, it looks like your table contains lookups - remove them, they mess up what you are trying to accomplish.

    Second, fix your naming conventions, it is all too confusing. Change all primary key fields to what it contains, e.g. SegmentID, and use that name on all other tables. Change fields to have more descriptive names, e.g. SegmentName. When designing a table, you are a techy, not a user, so use names that are absolute where there is no doubt as to what the field contains. Much of your confusion comes from this.

    tblWAID contains a field called "Segments" - with a name like this who knows what it contains. Your screenshot shows that it is storing the SegmentID (correctly). After you have changed the name of this field, go back to your work area row source query. The criteria says "this segment ID must match the segment ID which is in the first column of the combobox Segment" - which hopefully is the SegmentID.
    Thanks aytee111 for the quick response.

    I'm still getting lost. I removed the lookups on the fields tblSegID and tblWAID; Changed the fields "Segments" to SegID on both tblSegID and tblWAID. Here are the screen shots

    Click image for larger version. 

Name:	cascade 8.png 
Views:	11 
Size:	12.3 KB 
ID:	29040Click image for larger version. 

Name:	cascade 9.png 
Views:	11 
Size:	7.6 KB 
ID:	29041Click image for larger version. 

Name:	cascade 10.png 
Views:	11 
Size:	27.8 KB 
ID:	29042Click image for larger version. 

Name:	cascade 11.png 
Views:	11 
Size:	18.9 KB 
ID:	29043

  6. #6
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Good job!

    Set the column widths on the comboboxes so that the user doesn't see the id field.

    Did you follow all the instructions, including post # 2?

  7. #7
    raychow22 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    May 2017
    Posts
    145
    I think I did; I name SegID box "cboSeg" and WA box to "cboWA" with vba code as followed. I also set the criteria as shown on the work area row source for segid. Here are pictures.

    Click image for larger version. 

Name:	relationship.png 
Views:	11 
Size:	15.8 KB 
ID:	29044Click image for larger version. 

Name:	segidproperties.png 
Views:	11 
Size:	37.8 KB 
ID:	29045Click image for larger version. 

Name:	tblWAID query.png 
Views:	11 
Size:	21.6 KB 
ID:	29046Click image for larger version. 

Name:	VBA code.png 
Views:	11 
Size:	36.2 KB 
ID:	29047

  8. #8
    raychow22 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    May 2017
    Posts
    145
    Click image for larger version. 

Name:	waIDbox.png 
Views:	11 
Size:	46.8 KB 
ID:	29048One more

  9. #9
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    I can't see the criteria for the work area row source. Make sure that it matches the form. Not sure why it isn't working. Try changing Me.cboWA to Me!cboWA. Copy and paste the row source for cboWA into a new query window, then select a segment on the form and see if the query works. If not, change the criteria to a manual number and see if that works. Try and pinpoint exactly where the error is occurring.

    (On tblWAID, change the primary key to be WorkAreaID (never have spaces in names) and the name to WorkAreaName (or something like that). Don't use "ID" as a field name anywhere and use it only for primary keys/linked fields. This is a naming convention, not a rule. The result will help you for the life of the database.)

  10. #10
    raychow22 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    May 2017
    Posts
    145
    Oh BTW. I forgot to ask if the combo box can have multiple selections. Say Seg1 and Seg2 will display Work Areas for Seg1 and Seg2?

  11. #11
    raychow22 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    May 2017
    Posts
    145
    Click image for larger version. 

Name:	waIDbox.png 
Views:	10 
Size:	46.8 KB 
ID:	29049Click image for larger version. 

Name:	workareanumber.png 
Views:	10 
Size:	25.2 KB 
ID:	29050
    WA row source

  12. #12
    raychow22 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    May 2017
    Posts
    145
    Click image for larger version. 

Name:	cboWAProperties.png 
Views:	9 
Size:	22.3 KB 
ID:	29051Here it is.

  13. #13
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Multi-select comboboxes are not straightforward. I don't use them so can't help you. This might http://www.utteraccess.com/forum/Mul...-t1989417.html

  14. #14
    raychow22 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    May 2017
    Posts
    145
    Ok!!! I found the problem ; I forgot I changed cboSegment to "cboSeg"!!! Thanks aytee111 for helping me!! Now is there a way I can add multiple values of the combo box??

  15. #15
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Still nothing is apparent as to where the problem lies. Did you test the query?

    In the AfterUpdate sub type,
    Debug.Pring Me!cboSegment
    and see what is displayed

    (All tables should carry id's as foreign keys, the field with the control source of WA should be WorkAreaID and your row source should have that as the first column.)

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Cascading Combo Boxes
    By Heathey94 in forum Queries
    Replies: 26
    Last Post: 09-05-2016, 03:02 PM
  2. cascading Combo boxes
    By Chatholo in forum Forms
    Replies: 2
    Last Post: 08-09-2013, 01:39 AM
  3. Cascading combo boxes
    By Jackie in forum Access
    Replies: 5
    Last Post: 07-26-2013, 09:07 AM
  4. Cascading combo boxes
    By combine21 in forum Forms
    Replies: 3
    Last Post: 12-02-2010, 12:57 PM
  5. Cascading Combo Boxes
    By desireemm1 in forum Programming
    Replies: 1
    Last Post: 10-05-2009, 06:00 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