Hi,
Add all nine fields together, if they are all of text type, in a new column
in your query design. Then put in it's criteria:
LIKE "*" & [Search For:] & "*"
When you run the query you will be ask to fill in a search criteria "Search
For:". Every record will then be shown where the search criteria is found in
one or more of the nine columns. If you leave the serach criteria empty, the
all records will be shown.
You can use this principle on a form with a textbox for the search criteria
and the results shown in a subform (tabelview).
However you need to put the SQL statement of your query in the recordsource
of the subform and change the parameter field [Search For:] with the textbox
reference (for example [Forms]![frmSearch]![txtSearchFor] if those are the
names of your mainform and textbox). You also will need a "Search Now"
button which requeries the subform.
An SQL statement example with 4 fields for the subform (tabelview)
"frmSubSearchResults". Put it in the recordsource property of the subform
(change the tabelname and fields to your situation):
SELECT [Field1] & ";" & [Field2] & ";" & [Field3] & ";" & [Field4] AS
SearchFor, tblYourTable.Field1, tblYourTable.Field2, tblYourTable.Field3,
tblYourTable.Field4
FROM tblYourTable
WHERE ((([Field1] & ";" & [Field2] & ";" & [Field3] & ";" & [Field4]) Like
"*" & [Forms]![frmSearch]![txtSearchFor] & "*"));
Code behind the click event of the "SearchNow" button on the main form
"frmSearch" should be at least something like this:
Private Sub cmdSearchNow_Click()
Forms![frmSearch]![frmSubSearchResults].Requery
End Sub
Create a textbox "txtSearchFor" on your mainform "frmSearch".
That's it, Good luck!
Sid.
GLPM93 said:
I have created a query that looks at nine columns of the same type of data
in my database. Every time I want to search for something else, I have to
go and change each criteria for each column. I would like to be able to
have a device (a form maybe) where the search criteria could be inputted,
the change made to the query, query ran and results returned all at once.