Selecting specific information from a combo box

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm trying to figure out how to make a second combo box only show information
based on what is chosen in the first combo box on a form. For example, if in
the first combo box is a listing of all 50 states, and someone chooses Texas,
then in the second combo box, only Texas cities would show up.
 
Hi,


Whatever it is two or more combo box, the technique is the same. Say ComboB
has to have its list "updated" accordingly to the value in ControlA. I
assume you don't really mind to wait until the list of the combo box is
about to be displayed to indeed update it,

so, in the GotFocus event of ComboB,

Dim str AS String
str="SELECT whatever FROM somewhere "
If IsNull( Me.ControlA ) Then
'no more job to do
Else
str=str & " WHERE toBeRestricted= FORMS!FormNameHere!ControlA "
End IF

If str <> Me.ComboB.RowSource Then
Me.ComboB.RowSource = str
End if
' since modifying the RowSource FORCES a requery,
' we tested before, to avoid to requery, if it was
' required, instead of doing it unconditionally.
' Just some optimization.



And if ComboC depends on ComboB, you do similar stuff for ComboC, dependant
of ComboB, rather than ControlA, and so, and so.



Hoping it may help,
Vanderghast, Access MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top