Results 1 to 4 of 4
  1. #1
    LadyCroom is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2016
    Posts
    2

    How can I quickly find a record by searching for a text string in a specified field?


    My database has several dozen records. Each has a unique identifier and a number of fields, including a Title field. I'm looking for a way for users to jump to a specific record from the home page. I've tried creating a search box to search for text strings in the Title field, with the following event procedure behind a button, but it only searches on the first word in the Title field. In other words, if I have a Title such as "My Best Access Practices" and I enter "Practices" in the search box, there are no results. I would have to search on "My" (useless, right?) in order to pull up this record.

    This is what I'm using now behind the search button:

    Private Sub cmdSearch_Click()
    DoCmd.OpenForm "[frmName]", acNormal, , "[field name] like ' " & Me.txtSearch & " * ' "
    End Sub


    Is there an easy way to do this -- e.g., a query-based "directory"/datasheet for my home page showing all record Titles, and link those Titles to the actual record?

    Thanks, Wizards.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    You can add a wildcard at the beginning too:

    DoCmd.OpenForm "[frmName]", acNormal, , "[field name] like '*" & Me.txtSearch & "*' "

    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    LadyCroom is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2016
    Posts
    2
    Thank you - will try that.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    No problem, and welcome to the site by the way!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Find a record that contains a word in a string
    By knowshowrosegrows in forum Queries
    Replies: 2
    Last Post: 11-17-2015, 11:35 AM
  2. Replies: 8
    Last Post: 09-15-2015, 11:34 AM
  3. Replies: 6
    Last Post: 05-29-2015, 10:21 AM
  4. Trying to find a value right of specific string with in text
    By weilerda in forum Import/Export Data
    Replies: 2
    Last Post: 10-18-2012, 12:58 PM
  5. find all text string in Criteria at once
    By Jerseynjphillypa in forum Queries
    Replies: 3
    Last Post: 05-15-2012, 12:12 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums