Combo box filter

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

Guest

I am trying to base the options in one combo box ([Held]) off of another
([Type]). I have this for the AfterUpdate code of the first combo box.

The "Else" part of the code works. However, if [Type]=k, then the combo box
just shows the exact text :"SELECT [Por] FROM [S A M]"

I am also wondering how I can get the code to reset itself (go back to the
choices of "Name1" and "Name2" when I go to the next record. I am working on
a continous subform.

THANKS!!!


Private Sub Type_AfterUpdate()

If Me.Type = "k" Then
Me.Held.RowSource = "SELECT [Por] FROM [S A M]"
Else
Me.Held.RowSource = "Name1;Name2"

End If

End Sub
 
You also need to change the RowSourceType property:

Private Sub Type_AfterUpdate()
If Me.Type = "k" Then
Me.Held.RowSourceType = "Table/Query"
Me.Held.RowSource = "SELECT [Por] FROM [S A M]"
Else
Me.Held.RowSourceType = "Value List"
Me.Held.RowSource = "Name1;Name2"
End If
End Sub
 
Back
Top