Change code to search from"first part of field " to "any part of field"

Discussion in 'Microsoft Access Form Coding' started by mrmajix, Nov 15, 2003.

  1. mrmajix

    mrmajix Guest

    I have a form (InventorySearch) with a text box (txtEntry) which requeries
    the subform (InventorySearchSubform) on change. The search expression is
    linked to the field (Description). How can I change this code to search "any
    part of the field" instead of the "first part of field". Thanks in advance.

    Private Sub txtEntry_Change()
    Me!txtSearchExpression = Me!txtEntry.Text & "*"
    InventorySearchDetail.Requery

    Exit_txtEntry_Change:
    Exit Sub

    Err_txtEntry_Change:
    MsgBox Err.Description
    Resume Exit_txtEntry_Change
    End Sub
     
    mrmajix, Nov 15, 2003
    #1
    1. Advertisements

  2. mrmajix

    Wayne Morgan Guest

    It appears you are using the Like statement in the parameter of the query to filter the
    list. Placing a * in the front also should do what you want.

    "*" & Me!txtEntry.Text & "*"

    --
    Wayne Morgan
    Microsoft Access MVP


    "mrmajix" <> wrote in message
    news:C4rtb.10934$...
    > I have a form (InventorySearch) with a text box (txtEntry) which requeries
    > the subform (InventorySearchSubform) on change. The search expression is
    > linked to the field (Description). How can I change this code to search "any
    > part of the field" instead of the "first part of field". Thanks in advance.
    >
    > Private Sub txtEntry_Change()
    > Me!txtSearchExpression = Me!txtEntry.Text & "*"
    > InventorySearchDetail.Requery
    >
    > Exit_txtEntry_Change:
    > Exit Sub
    >
    > Err_txtEntry_Change:
    > MsgBox Err.Description
    > Resume Exit_txtEntry_Change
    > End Sub
    >
    >
     
    Wayne Morgan, Nov 15, 2003
    #2
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Paul James

    filtering to match any part of a field

    Paul James, Mar 23, 2004, in forum: Microsoft Access Form Coding
    Replies:
    2
    Views:
    268
    Paul James
    Mar 24, 2004
  2. Paul James
    Replies:
    0
    Views:
    197
    Paul James
    May 3, 2004
  3. Burandi

    How ? Multiple entries: part same, part different ?

    Burandi, Oct 6, 2004, in forum: Microsoft Access Form Coding
    Replies:
    0
    Views:
    153
    Burandi
    Oct 6, 2004
  4. Guest

    aceditmenu option to match any part of the field

    Guest, May 27, 2005, in forum: Microsoft Access Form Coding
    Replies:
    4
    Views:
    9,352
    NGomes
    Dec 11, 2006
  5. Guest

    Code to search all columns in a table for a single search word

    Guest, Jun 1, 2005, in forum: Microsoft Access Form Coding
    Replies:
    4
    Views:
    279
    Graham Mandeno
    Jun 4, 2005
Loading...

Share This Page