Results 1 to 4 of 4
  1. #1
    JennyL is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jan 2017
    Posts
    51

    Cascading Comboboxes


    Hi,

    I am creating another database and need to create two comboboxes, the second combobox rowsource needs to change depending on the selection of first combobox. From googling, I believe it is called Cascading comboxes.

    I have tested both of the following codes, using IF/Then, and Select Case statements. they both seem to work but not work if one is better than the other. I also want to add that if user select "Other" on the first comboxbox then the rowsource for the second combobox should be blank and any previous information should be cleared out. Any advise on what I will need to add to the code to clear out the rowsource?


    If/Then Statement

    Private Sub QueryType_AfterUpdate()
    If Me.QueryType.Value = "USD Box" Then
    Acct.RowSource = "Qry_USDLB"

    ElseIf Me.QueryType.Value = "RCD" Then
    Acct.RowSource = "Qry_RCD"
    End If
    End Sub


    Select CAse Statement
    Select Case QueryType.Value
    Case "USD box"
    Acct.RowSource = "Qry_USDLB"

    Case "RCD"
    Acct.RowSource = "Qry_RCD"
    End Select

  2. #2
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,049
    Select case easier especially for the "other" option

    Case "other"
    Acct.rowsource =""




    Sent from my iPhone using Tapatalk

  3. #3
    JennyL is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jan 2017
    Posts
    51
    Thank you!

    One more question, how do I add the code to say anything besides the options listed in the "case statement" change row source to ""?



    Quote Originally Posted by andy49 View Post
    Select case easier especially for the "other" option

    Case "other"
    Acct.rowsource =""




    Sent from my iPhone using Tapatalk

  4. #4
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,049
    Case else

    Do what you want it to

    End select


    Sent from my iPhone using Tapatalk

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

Similar Threads

  1. can Memo field be used in cascading comboboxes
    By macaulayrg2003 in forum Forms
    Replies: 6
    Last Post: 02-27-2013, 12:01 PM
  2. Trouble with Cascading ComboBoxes
    By shane201980 in forum Programming
    Replies: 3
    Last Post: 10-03-2012, 09:05 AM
  3. Cascading ComboBoxes
    By GAccess in forum Forms
    Replies: 1
    Last Post: 03-06-2012, 05:02 AM
  4. Symmetric Cascading Comboboxes
    By schwabe in forum Forms
    Replies: 15
    Last Post: 02-02-2012, 11:38 AM
  5. Cascading Comboboxes and Sub Forms
    By PaulCW in forum Forms
    Replies: 6
    Last Post: 10-07-2011, 12:08 PM

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