Results 1 to 6 of 6
  1. #1
    ttn022191 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2014
    Posts
    2

    Help creating a search form

    Hello all,

    I need help creating a search form. I have no knowledge of SQL and I've looked at many examples and can't seem to figure this out. I've attached the database and hopefully someone can give me some help with the SQL code to create this search form. I created the layout of how I want to the search form to look like and it is saved as "ReadingSearchForm". It has 5 multi-select list boxes and 4 combo boxes. I want the user to select the criteria from the list boxes and combo boxes and the information will appear in a subform.

    If anybody could help me that would be great!

    Example.zip

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    You would have to inspect each control to see if they picked it. like:
    On Search_click()

    Code:
    dim sSql as string, sWhere as string
    
    if not isnull(cboState) then     sWhere = sWhere & " and [state]='" & cboState & "'"
    if not IsNull(txtName) then    sWhere = sWhere & " and [Name]='" & txtName & "'"
    if not IsNull(chkContact) then    sWhere = sWhere & " and [Contact]=" & chkContact.value
    
        'remove 1st And
    sWhere= mid(sWhere,4)
    sSql = "SELECT * FROM tblCompany WHERE "
    sSql = sSql & sWhere
    
    frmResults.Recordsource = sSql

  3. #3
    ttn022191 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2014
    Posts
    2
    I don't really understand this...

  4. #4
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    The user can click on any 1 or more , of the elements on the page. Youd have to inspect all of them to determine what is wanted.
    The result is in the sub form.

    Unless you understand access, this is a simple as I can make it.

  5. #5
    AlexHedley's Avatar
    AlexHedley is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Apr 2013
    Location
    England
    Posts
    180

    Help creating a search form

    Have a go replicating this idea, it uses a textbox to get the Search Criteria but if you understand this then you can expand it to use your controls.

    https://599cd.com/tips/access/multi-...rch-form-like/

  6. #6
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    You might have a look at this tutorial to get you started. You can modify your form once you understand the basics from this video.

    http://www.datapigtechnologies.com/f...earchform.html

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

Similar Threads

  1. Creating a Search Form
    By midnight_puppy_2303 in forum Forms
    Replies: 5
    Last Post: 08-04-2014, 09:29 AM
  2. Creating a Search Form using query
    By sam.eade in forum Queries
    Replies: 2
    Last Post: 09-07-2013, 03:55 AM
  3. Need help in creating Search Form
    By bnar in forum Forms
    Replies: 2
    Last Post: 06-05-2012, 12:09 AM
  4. creating a search form
    By foxtet in forum Forms
    Replies: 4
    Last Post: 08-06-2011, 06:08 AM
  5. Creating an Access Search Form
    By Icky_Joe in forum Forms
    Replies: 2
    Last Post: 08-16-2010, 11:33 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