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?
Printable View
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?
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 :
I am not going to go through how to add it to the grid, that should be the easy part.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
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?
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?