Results 1 to 4 of 4

Thread: Executing a search in ADO

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jun 2000
    Posts
    132

    Red face

    Yeah i have a problem.
    I have 7 textboxes and i want to be able to search all of the text boxes at once and then display the results on a Datagrid. How do i do this?
    Reality is an illusion caused by by lack of drugs

    Is this real or am i just having a dream?

  2. #2
    Hyperactive Member
    Join Date
    Mar 2000
    Posts
    461
    1. Add a textbox to a form
    2. Copy It
    3. Paste it and say "Yes" to create a "Control Array"
    4. Do this as many times as you like

    To construct the query :

    Code:
    Dim i as Integer
    
    sSql = "SELECT * FROM SearchTable WHERE " <-- Notice the space
    
    sWhere = ""
    For i = 0 to TextBox1.Count - 1
      If Trim(TextBox1(i).Text) <> "" Then
        If sWhere <> "" Then
          sWhere = sWhere & "AND "
        End If
        sWhere = sWhere & "SearchField like '%" & TextBox1(i).Text & "%' " <- Another space at the end
      End If
    Next i
    
    rstResults.OpenRecordset sSql & sWhere, adoConnection, adOpenStatic, adOpenReadONly, adCmdText
    
    ' Clear the DataGrid
    
    Do While not rstResults.Eof
      ' Add a new item to the datagrid
      rstResults.MoveNext
    Loop
    rstResults.Close
    set rstResults = nothing
    I am not going to go through how to add it to the grid, that should be the easy part.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jun 2000
    Posts
    132
    Ok i did that but when it runs it says that an object is required and highlights the line "rstResults.OpenRecordset sSql & sWhere, adoConnection, adOpenStatic, adOpenReadONly, adCmdText"

    Would this be because i have to set this line to the recordsource of the adodc?
    Reality is an illusion caused by by lack of drugs

    Is this real or am i just having a dream?

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Jun 2000
    Posts
    132
    Hey could anybody help me....

    The line;
    rstResults.OpenRecordset sSql & sWhere, adoConnection, adOpenStatic, adOpenReadONly, adCmdText <- Error object required.

    Do i have to set this to the ADODC or the MSHFlexGrid?
    Reality is an illusion caused by by lack of drugs

    Is this real or am i just having a dream?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width