469,887 Members | 1,334 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,887 developers. It's quick & easy.

Creating a dropdown list box that will call another dropdown list box in access.

Hello All,
I am creating a date base in access. I want to create a dropdown list box that is connected to another dropdown list box.
You start with a dropdown list that has 5 choices and each of these choices will call another dropdown list box when one of the choices from the first gets selected. (I hope this makes sense)

All of this is being done on a single form.
I know how to make a (sub) dropdown list not seen before the action and disappear after the action. I do not know the coding for a sub dropdown list box.
If there is a website that covers this that would be great, or if some one know the name of the action I am trying to do that would be great. I have been trying to search the web and by library for any clues but I am coming up short.
I really appreciate the help.
Mar 4 '08 #1
3 2485
145 100+
Where are the other values stored? In a table?
Mar 4 '08 #2
all the values are stored In the same table.
Mar 4 '08 #3
145 100+
all the values are stored In the same table.
Many ways to do this.

My approach would be to create a global dictionary containing key/value pairs where the value is a delimited sequence of data that should be inserted into the other combobox.

In other words, something like

Expand|Select|Wrap|Line Numbers
  1. Public d As New Dictionary 'Scope to global (public) so we can use the dictionary elsewhere in code. 
  3. '**set a reference to Microsoft Scripting Runtime or scrrun.dll 
  4. '   otherwise, declare d as variant and set it to CreateObject("Scripting.Dictionary")
  6. d.add "Combo1KeyText", "Value1^Value2^Value3^Value4"
  7. d.add "Combo2KeyText", "Value1^Value2" 
  8. d.add "Combo3KeyText", "Value1^Value2^Value3" 
Then, capture the comboboxes changed event and load the Values list into the other combobox.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Combo1_Change()
  2.    Dim sValues As String 
  3.    Dim varValues
  4.    Dim i as Integer
  5.    If d.Exists(Combo1.Text) Then 'd is our global dictionary object
  6.       Combo2.Clear 
  7.       sValues = d(Combo1.Text) 
  8.       varValues = Split(sValues, "^") 
  9.       For i = 0 to ubound(varValues)
  10.          Combo2.AddItem varValues(i) 
  11.       Next i 
  12.    End If 
  13. End Sub
Mar 4 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

8 posts views Thread by Kris Rockwell | last post: by
2 posts views Thread by Mike Collins | last post: by
9 posts views Thread by Tarscher | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.