Combo box filter

A

awach

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
 
K

Ken Snell \(MVP\)

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
 

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

Top