G
Guest
Is possible to synchronize three or more combo box at once? If do, can show
me the way or the code please, thanks for the support.
me the way or the code please, thanks for the support.
Douglas J. Steele said:You can put code in the AfterUpdate event of combo1 to change the
RecordSource for combo2, and code in the AfterUpdate event of combo2 to
change the RowSource for combo3 and so on:
Private Sub Combo1_AfterUpdate()
Dim strSQL As String
strSQL = "SELECT Field2, Field3 " & _
"FROM Table2 " & _
"WHERE Field1 = " & Me.Combo1 & _
" ORDER BY Field3"
Me.Combo2.RowSource = strSQL
End Sub
Private Sub Combo2_AfterUpdate()
Dim strSQL As String
strSQL = "SELECT Field4, Field5 " & _
"FROM Table3 " & _
"WHERE Field1 = " & Me.Combo1 & _
" AND Field2 = " & Me.Combo2 & _
" ORDER BY Field5"
Me.Combo3.RowSource = strSQL
End Sub
etc.
You can also have the SQL statement that makes up the RowSource for combo2,
combo3, etc have a reference to the previous combo box(es). In other words,
the RowSource for Combo2 could be
SELECT Field2, Field3 FROM Table2 WHERE Field1 = [Forms]![Form1]!{Combo1]
ORDER BY Field3
You'd then invoke the Requery method for the combo box once a value has been
selected in the previous combo:
Private Sub Combo1_AfterUpdate()
Me.Combo2.Requery
End Sub
--
Doug Steele, Microsoft Access MVP
(no e-mails, please!)
Info said::
picking something
in combo1 that will cause the values in combo2 to be filtered to a smaller
list, and picking something in combo2 will cause the values in combo3 to
be
filtered to a smaller list
This one,thanks.
ccg said:Hi Douglas and anyone else who sees this,
I'm trying to do something similar to what "Info" asked, except I need a
third combo box to limit its options after a selection is made for the second
combo box. Is there a way to do that?
I need to choose a RoleLevel, then limit RoleCategory by what is selected in
RoleLevel. Then I need to limit Role by what is selected in RoleCategory.
I followed the instructions on this page -
http://msdn.microsoft.com/en-us/library/bb404901.aspx - to do the first set,
but I can't figure out how to get the second set to work. I'm stumped.
Can someone help? I would appreciate it very much! Thanks!
(I am working in Access 2007.)
Douglas J. Steele said:You can put code in the AfterUpdate event of combo1 to change the
RecordSource for combo2, and code in the AfterUpdate event of combo2 to
change the RowSource for combo3 and so on:
Private Sub Combo1_AfterUpdate()
Dim strSQL As String
strSQL = "SELECT Field2, Field3 " & _
"FROM Table2 " & _
"WHERE Field1 = " & Me.Combo1 & _
" ORDER BY Field3"
Me.Combo2.RowSource = strSQL
End Sub
Private Sub Combo2_AfterUpdate()
Dim strSQL As String
strSQL = "SELECT Field4, Field5 " & _
"FROM Table3 " & _
"WHERE Field1 = " & Me.Combo1 & _
" AND Field2 = " & Me.Combo2 & _
" ORDER BY Field5"
Me.Combo3.RowSource = strSQL
End Sub
etc.
You can also have the SQL statement that makes up the RowSource for combo2,
combo3, etc have a reference to the previous combo box(es). In other words,
the RowSource for Combo2 could be
SELECT Field2, Field3 FROM Table2 WHERE Field1 = [Forms]![Form1]!{Combo1]
ORDER BY Field3
You'd then invoke the Requery method for the combo box once a value has been
selected in the previous combo:
Private Sub Combo1_AfterUpdate()
Me.Combo2.Requery
End Sub
--
Doug Steele, Microsoft Access MVP
(no e-mails, please!)
Info said::
picking something
in combo1 that will cause the values in combo2 to be filtered to a smaller
list, and picking something in combo2 will cause the values in combo3 to
be
filtered to a smaller list
This one,thanks.
What do you mean by synchronize? Do you want it such that picking something
in combo1 that will cause the values in combo2 to be filtered to a smaller
list, and picking something in combo2 will cause the values in combo3 to be
filtered to a smaller list, or do you want it such that if you pick the 3rd
item in combo1, specific items will be selected in combo2 and combo3?