Results 1 to 3 of 3
  1. #1
    Jlb1108 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2019
    Posts
    2

    Multiple field search box using a drop down box for field and text box for criteria

    This is my first access database and I need assistance building a search box that allows the user to choose which field to perform his or her search on. The multiple field combo box returns to many like results to be functional because most of my date is similarly structured( part #s, PO#s, serial #s, item #s, etc). So I need a list box the refers to fields and a text or combo box that contains the search criteria. I feel like this should be easy but I have yet to find video or forum that uses this approach. All help is appreciated

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    I do something like this. User selects field in combobox. Then VBA code changes the RowSource of second combobox to only show DISTINCT values from the selected field. Something like:

    Code:
        Me.cbxFor.RowSource = "SELECT DISTINCT " & Me.cbxField & _
                        " FROM Projects INNER JOIN Submit ON Projects.ProjRecID = Submit.ProjRecID" & _
                        " WHERE Not " & Me.cbxField & " Is Null " & _
                        " ORDER BY " & Me.cbxField & ";"
    Now applying the selection of the second combobox as filter criteria gets rather complicated if the fields are different data types. Fortunately, not dealing with number data types on this particular form.

    I have comboboxes for text type fields and values then textboxes for input of date range. VBA code conditionally builds the criteria string. Review http://allenbrowne.com/ser-62.html

    Advise not to use spaces nor punctuation/special characters (underscore only exception) in naming convention. If you do, code will have to be modified so all object names will be enclosed in [ ] characters in the compiled SQL string.
    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.

  3. #3
    Jlb1108 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2019
    Posts
    2
    Thank you. I'll give that a try today.

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

Similar Threads

  1. Replies: 2
    Last Post: 05-17-2017, 06:17 AM
  2. Replies: 1
    Last Post: 11-30-2016, 03:41 AM
  3. Replies: 4
    Last Post: 10-14-2015, 02:33 AM
  4. Replies: 8
    Last Post: 09-02-2015, 03:00 PM
  5. Replies: 3
    Last Post: 09-02-2013, 04:33 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