Filter by form woes (posted inadvertantly first in the queries sub

B

bjnova

I tried posting something like this already but am still flummoxed. I got
most of the following code from this forum but it doesn't work for me. I
have an unbound combobox on a form bound to a table. The user gets to
select
a value from the combobox and the items in the combobox are the first three
letters of one or more of the records in the table. So, once the choice is
made, I would like the user to be able to move through a recordset
restricted
(in the first three charcters) by their choice. The choice of all (no
filter) works great; none of the other choices give any results at all.

Any help?

Private Sub cboChooseRecords_AfterUpdate()
If Me.Dirty Then 'Save before filter
Me.Dirty = False
End If

With Me.cboChooseRecords
'.value=9 corresponds to the all records choice in the combobox
If (.Value = 9) Then ' show all.

Me.FilterOn = False
Else
'MsgBox (Me!screenID)
' MsgBox (cboChooseRecords.Column(1))
'screenID is the name of the table field that is being filtered
' four single place wildcards; first three come from the cbo
Me.Filter = "[screenID] Like ""cboChooseRecords.Column(1)" &
"????"""
Me.FilterOn = True
End If
Me.Detail.Visible = True
End With

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