Filter by form woes

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

Guest

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.

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

With Me.cboChooseRecords

If (.Value = 9) Then 'nothing entered: show all.

Me.FilterOn = False
Else
'MsgBox (Me!screenID)
MsgBox (cboChooseRecords.Column(1))
'screenname is the name of the control that will show the filtered
results
' four single place wildcards since the first three match the value
chosen in the combobox
Me.Filter = "[screenID] Like ""cboChooseRecords.Column(1)" & "????"""
Me.FilterOn = True
End If
Me.Detail.Visible = True
End With

End Sub
 
Back
Top