Fred,
Here is the current clip of code that I am using:
Private Sub Combo6_AfterUpdate()
Dim strSQL As String
strSQL = "Select " & Me!Combo4
strSQL = "charge code" strSQL & "Table1"
Me!Combo6.RowSourceType = "Table/Query"
Me!Combo6.RowSource = strSQL
End Sub
So I don't know if it is possible to use this code, modify it, or if I have
to get a completely new piece of code.
Tim
I have no idea of what your code actually does nor what you are trying
to accomplish with it.
You need to code the AfterUpdate event of the first combo box selected
so that it's value can be used to filter the records shown in the
other combo box.
Reading your code, your somehow trying to code the same combo box
(combo6) afterupdate event to alter it's own values. That's not what
you said in your original post "I have 2 linked combo boxes ... etc"
Try something like this:
Private Sub FirstComboBox_AfterUpdate()
Dim strSQL As String
strSQL = "Select TableName.[FieldName] From TableName "
strSQL = strSQL & "Where TableName.[SomeFieldName] = " &
Me![FirstComboName]
Me!SecondComboName.RowSourceType = "Table/Query"
Me!SecondComboName.RowSource = strSQL
End Sub
Make sure you have left a space between Tablename and the " on the
first strSQL = line.
1) You'll need to change the name of the AfterUpdate event to that of
the control in which it is placed. Private Sub Combo6_afterUpdate is
OK IF Combo6 is the name of the control used to limit the records in
the second control. Or is Combo4 the name of that first combo box.
2) You'll need to change TableName to the name of the table from
which you are getting this data.
3) You'll need to change the field [FieldName] to the name of the
field you wish to display in the second combo box.
4) You'll need to change the field [SomeFieldName] to the name of the
field used for criteria.
5) As written, the above SQL assumes the bound column of the first
combo box is a number datatype.
If, in fact, the bound column is a Text datatype, change the SQL to:
strSQL = "Select TableName.[FieldName] From TableName "
strSQL = strSQL & "Where TableName.[SomeFieldName] = '" &
Me![FirstComboName] & "'"
For more information on this subject see:
http://www.mvps.org/access/forms/frm0028.htm
and/or search
http://groups.google.com
for cascading combo boxes.