Results 1 to 4 of 4
  1. #1
    Join Date
    May 2013
    Posts
    19

    Search Box "Contains"

    Hi I have a search box running the following code on After Update. I would like the search box to use a contains functionality instead of its exact nature currently.

    ex. "Address Number" could be found by typing "Num". Currently I have to type "Address Number" in full exactly as it appears in my table.

    Any help would be greatly appreciated.

    Thanks

    Code:
    Private Sub txtSearch_AfterUpdate()
    With Me.RecordsetClone
       .FindFirst "[QstnText]=""" & Me.txtSearch & """"
       If .NoMatch Then
          Beep
       Else
          Me.Bookmark = .Bookmark
       End If
       End With
    End Sub


  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,652
    Try


    .FindFirst "[QstnText] Like " & Chr(34) & "*" & Me.txtSearch & "*" & Chr(34)
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Join Date
    May 2013
    Posts
    19
    Thank you very much! It worked perfectly. As a side note is the same functionality applicable to a combo box? You can jump to a record by typing in the box but it uses the "begins with" functionaluty. I have tried modifying the above code in mine below but it doesnt seem to work. Any suggestions?

    Thank you once again!

    Sub CboMoveTo_AfterUpdate()
    Dim rs As DAO.Recordset

    If Not IsNull(Me.CboMoveTo) Then
    'Save before move.
    If Me.Dirty Then
    Me.Dirty = False
    End If
    'Search in the clone set.
    Set rs = Me.RecordsetClone
    rs.FindFirst "[QstnID] = " & Me.CboMoveTo
    If rs.NoMatch Then
    MsgBox "Not found: filtered?"
    Else
    'Display the found record in the form.
    Me.Bookmark = rs.Bookmark
    End If
    Set rs = Nothing
    End If

  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,652
    What did you try? You need to use Like and wildcards. I can't think of a way around the automatic behavior of a combo while typing offhand.
    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. Replies: 11
    Last Post: 06-18-2013, 07:48 AM
  2. Replies: 8
    Last Post: 03-05-2013, 01:20 PM
  3. Export "Query or Report" to a "Delimited Text File"
    By hawzmolly in forum Import/Export Data
    Replies: 3
    Last Post: 08-31-2012, 08:00 AM
  4. Replies: 11
    Last Post: 03-29-2012, 02:32 PM
  5. Replies: 16
    Last Post: 07-22-2011, 09:23 AM

Tags for this Thread

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