By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,137 Members | 2,242 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,137 IT Pros & Developers. It's quick & easy.

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

P: 8
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
Share this Question
Share on Google+
3 Replies


VBWheaties
100+
P: 145
Where are the other values stored? In a table?
Mar 4 '08 #2

P: 8
all the values are stored In the same table.
Mar 4 '08 #3

VBWheaties
100+
P: 145
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. 
  2.  
  3. '**set a reference to Microsoft Scripting Runtime or scrrun.dll 
  4. '   otherwise, declare d as variant and set it to CreateObject("Scripting.Dictionary")
  5.  
  6. d.add "Combo1KeyText", "Value1^Value2^Value3^Value4"
  7. d.add "Combo2KeyText", "Value1^Value2" 
  8. d.add "Combo3KeyText", "Value1^Value2^Value3" 
  9.  
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
  14.  
Mar 4 '08 #4

Post your reply

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