Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2014
    Posts
    1

    Unanswered: 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!
    Attached Files Attached Files

  2. #2
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    496
    Provided Answers: 24
    Answered on the other board. On search button click: use vb code to determine what user selected.
    Then put the sql into the form to view the results.

    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

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
  •