Results 1 to 3 of 3
  1. #1
    DaneTrain24 is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Jan 2016
    Posts
    13

    Using Radio Buttons to Only Search Through One Column

    I want to add radio buttons to my search form that will limit the text search to only the column specified with the radio button. For example, if the first radio button is selected I only want the form to search for the matching text in column 1, not throughout the enter form. If the second radio button is selected I only want the form to search for the text in column 2. So on and so on.



    Do I need to put the code in the radio button 'on got focus' event or in the txtsearch event? I essentially need the radio buttons to act as a filter for my txtSearch.

    I also need the search to only find exact matches. For example, I have both "dishwasher" and "washer" as data in my form. If I search 'washer' I do not want any 'dishwasher data' to pull.


    My current code is below:

    Private Sub Command662_Click()
    Dim strsearch As String
    Dim strTextsearch As String
    strText = Me.TxtSearch.Value
    strsearch = "SELECT * from ProcurementDatabase where ([SKU #] like ""*" & strText & "*"") or (Supplier like ""*" & strText & "*"") or ([Item Type] like ""*" & strText & "*"") or (Model like ""*" & strText & "*"") or (Property like ""*" & strText & "*"")"
    Me.RecordSource = strsearch
    End Sub




    Private Sub TxtSearch_AfterUpdate()
    Call Command662_Click
    End Sub

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    Hmm?? Where does your code involve the radio button(s)?

    Seems to me you would have to
    1-identify the field to search
    2-type the string for the search/criteria
    3 - build the actual query/filter based on 1 and 2


    Code:
    SELECT * FROM TABLE
    WHERE field identified in 1 = "criteria from 2"

  3. #3
    DaneTrain24 is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Jan 2016
    Posts
    13
    I didn't include the code for the radio buttons because I wasn't sure where to put it.

    So my code would look like:

    Select * From Table
    WHERE [Item Type] = "strText"

    So would I put that under the radio button event? And do the same for each radio button? The string for the search would be entered into the search bar. I just need the radio button to filter. I don't want to search to happen until I enter the text and hit search.

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

Similar Threads

  1. Radio Buttons
    By maguyver in forum Access
    Replies: 3
    Last Post: 07-07-2012, 10:39 AM
  2. Radio Buttons
    By ccordner in forum Forms
    Replies: 1
    Last Post: 01-27-2012, 09:56 AM
  3. Radio Buttons
    By neil123williams in forum Forms
    Replies: 8
    Last Post: 11-11-2011, 03:38 PM
  4. what happened to radio buttons?
    By judomum in forum Forms
    Replies: 1
    Last Post: 10-09-2011, 11:58 AM
  5. radio buttons from 97 to 2010
    By mmm in forum Access
    Replies: 0
    Last Post: 12-03-2010, 04:20 PM

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