Results 1 to 2 of 2
  1. #1
    vha7 is offline Advanced Beginner
    Windows 10 Access 2010 64bit
    Join Date
    Jul 2018
    Posts
    46

    How to create two keyword text box searches?

    Hi everyone,



    Right now I have a text box to search any keyword in the respective fields (in this case, this keyword searches any name within the "Last Name" column and the "First & Middle Name" column)

    I am wondering how I would go about having two textboxes for their respective fields to search for the record of interest?
    i.e I would like to have one textbox for "Last Name", be able to click search to show up all the results for lets say those who have the last name as "McDonald" and then when I enter a second textbox for "First & Middle Name", it will search for the name i type in within the previous filtered search of :McDonald" as the last name.

    This is the code I have so far for my single textbox search that searches within the two fields of LAST NAME and FIRST & MIDDLE NAME:

    Private Sub btnSearch2_Click()
    Dim SQL3 As String

    SQL3 = "SELECT [IDList].[ID], [IDList].[TRANSACTION CODE], [IDList].[LAST NAME], [IDList].[FIRST & MIDDLE NAME], [IDList].[SPECIALTY], [IDList].[INTEREST], [IDList].CITY, [IDList].PROVINCE, [IDList].[POSTAL CODE], [IDList].[CODE] " _
    & "FROM [IDList] " _
    & "WHERE [LAST NAME] LIKE '*" & Me.txtKeywordz & "*' " _
    & " OR [FIRST & MIDDLE NAME] LIKE '*" & Me.txtKeywordz & "*' " _
    & " OR [ID] LIKE '*" & Me.txtKeywordz & "*' " _
    & " ORDER BY [IDList].[LAST NAME]; " _

    Me.subFIND.Form.RecordSource = SQL3
    Me.subFIND.Form.Requery

    End Sub

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    Well, use two textboxes then probably use AND operator.

    Review http://allenbrowne.com/ser-62.html
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replies: 2
    Last Post: 08-10-2018, 09:08 AM
  2. Replies: 2
    Last Post: 11-10-2017, 07:52 PM
  3. Replies: 8
    Last Post: 07-07-2017, 04:53 PM
  4. Replies: 17
    Last Post: 03-14-2016, 02:48 PM
  5. Replies: 6
    Last Post: 02-02-2015, 02:14 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