Recordset Filter Problem

Private Sub txtSearchBox_Change()
If txtPartN = "" Or txtSearchBox = "" Then
Adodc1.Recordset.Filter = ""
Adodc1.Refresh
Exit Sub
End If
Adodc1.Recordset.Filter = txtPartN.Text & " Like '*" & txtSearchBox.Text & "*'"
End Sub
'What's wrong with this code? Pls help me..

Comments

  • seancampbellseancampbell Pennsylvania, USA
    : Private Sub txtSearchBox_Change()
    : If txtPartN = "" Or txtSearchBox = "" Then
    : Adodc1.Recordset.Filter = ""
    : Adodc1.Refresh
    : Exit Sub
    : End If
    : Adodc1.Recordset.Filter = txtPartN.Text & " Like '*" & txtSearchBox.Text & "*'"
    : End Sub
    : 'What's wrong with this code? Pls help me..
    :

    What exactly are you doing?

    You don't have to put a full SQL statement in for filter? (I don't use datcontrols much any more)
  • How to use ComboBox as lookup box for a basic data entry form.
    That is, binding a ComboBox to database lookup table using ADO control.

    I have 2 ADO controls on the form:

    1. ComboBox to specify field in the Table Products.
    2. SearchBox for searching/filtering through the Recordset based on ComboBox.

    I have Items.mdb with Table Products which fields are Part No and Serial No. And I want to bind ComboBox to specify field in the Table Products.

    Pls help..
  • : Private Sub txtSearchBox_Change()
    : If txtPartN = "" Or txtSearchBox = "" Then
    : Adodc1.Recordset.Filter = ""
    : Adodc1.Refresh
    : Exit Sub
    : End If
    : Adodc1.Recordset.Filter = txtPartN.Text & " Like '*" & txtSearchBox.Text & "*'"
    : End Sub
    : 'What's wrong with this code? Pls help me..
    :


    try using % instead of * as the wildcard :

    [code]

    Adodc1.Recordset.Filter = txtPartN.Text & " Like '%" & txtSearchBox.Text & "%'"

    [/code]
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories