Results 1 to 3 of 3
  1. #1
    skelsey is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2020
    Posts
    1

    Needing to search by checkbox and/or text box criteria

    I have 4 different checkboxes (BridgeCheck, LandscapeCheck, RoadCheck, TrafficEngCheck), along with a text box (txtSearch and a search button (goButton). I am wanting to be able to 1) check one of the checkboxes and click the search button or 2) check one of the checkboxes type text in the text box and click the search button and only get those matching records. I have been scratching my head on how to do this. I would appreciate any help. Thank you in advance.

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2016
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    14,609
    Here is a link to an often referenced search by Allen Browne. You may get some ideas from the article.

  3. #3
    ranman256's Avatar
    ranman256 is online now VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    7,910
    Test all controls for a possible filter then build the where clause:
    Code:
    sub btnFind_click()
    sWhere = "1=1"
    if not isnull(cboState) then   sWhere = sWhere & " and [state]='" & cboState & "'"
    if not IsNull(txtName) then    sWhere = sWhere & " and [Name]='" & txtName & "'"
    if  chkContact then sWhere = sWhere & " and [Contact]=" & chkContact.value
    
     'then filer
    me.filter = sWhere
    me.filterOn = true
    end sub

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

Similar Threads

  1. Replies: 2
    Last Post: 01-28-2019, 06:32 AM
  2. Replies: 3
    Last Post: 09-12-2016, 11:49 AM
  3. Replies: 1
    Last Post: 03-26-2015, 11:08 AM
  4. Replies: 3
    Last Post: 01-04-2015, 06:09 PM
  5. using checkbox as iif criteria
    By TheShabz in forum Queries
    Replies: 3
    Last Post: 01-18-2011, 05:10 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
  •  
Tech Forums: Microsoft Office Forums