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?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Similar Threads
  1. Connel Valentine

    Search Code?

    Connel Valentine, Sep 21, 2003, in forum: Microsoft Access Form Coding
    Replies:
    1
    Views:
    188
    Arvin Meyer
    Sep 21, 2003
  2. Paul James
    Replies:
    0
    Views:
    286
    Paul James
    May 3, 2004
  3. Harmannus

    Change search code?

    Harmannus, Jul 12, 2004, in forum: Microsoft Access Form Coding
    Replies:
    2
    Views:
    198
    Harmannus
    Jul 12, 2004
  4. Guest

    Search form with list box doesn't search

    Guest, May 3, 2005, in forum: Microsoft Access Form Coding
    Replies:
    1
    Views:
    255
    Nikos Yannacopoulos
    May 4, 2005
  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:
    375
    Graham Mandeno
    Jun 4, 2005
  6. timhysniu

    ACC2000: Can't do AND Search using 2 search keys?

    timhysniu, Jul 22, 2005, in forum: Microsoft Access Form Coding
    Replies:
    0
    Views:
    255
    timhysniu
    Jul 22, 2005
  7. dgodfrey

    Search Form to search everything

    dgodfrey, Jul 2, 2008, in forum: Microsoft Access Form Coding
    Replies:
    1
    Views:
    208
    KARL DEWEY
    Jul 3, 2008
  8. Annette

    Search form - results excluding search request

    Annette, Oct 2, 2008, in forum: Microsoft Access Form Coding
    Replies:
    0
    Views:
    357
    Annette
    Oct 2, 2008
Loading...