Search Control

sebastian341

Registered User.
Local time
Today, 15:15
Joined
Jun 11, 2009
Messages
21
Is there anything similar to a search control in a form? I want the user to be able to search all the records as if they had typed in their parameter in that bottom search box, at the bottom of all forms and tables. However, the people who will be using this database arent computer-friendly, so I want a nice and big search field higher up that does the same thing as the lower one.

Is there any simple control that would do this or would I have to use VB with a text box?

Thanks
 
If I'm understanding you correctly, they are relatively easy to make. I created a blank form, set the data source to a query I have, then created an unbound text box on the form with a command button. Then all I had to do was set the criteria for the field in my query I wanted searchable to the text box on the form, and configure the command button on the form to requery.

As a side note, you would not be able to run this query without the form being open in the future though.
 
I created a blank form, set the data source to a query I have, then created an unbound text box on the form with a command button. Then all I had to do was set the criteria for the field in my query I wanted searchable to the text box on the form, and configure the command button on the form to requery.

Could someone explain this to me?
 
Then all I had to do was set the criteria for the field in my query I wanted searchable to the text box on the form, and configure the command button on the form to requery.

This bit :o
 

To start, I use Access 2007, but it shouldn't really matter which version you're using. I created a blank form, double-clicked at the very top left in Design view to set its properties, and set the "Record Source" field under the Data tab to my query. Then I created a text box on my form for the search criteria to go into, went to its properties and named it "txtSearch" (you can name it whatever you want). Last, I created a button on the form and named it "cmdSearch" (again, name it as you like).

Then to link my query to the search box, I opened the query in Design view, went to the column of the field I wanted the search to apply to, and put in the following under Criteria: Like "*" & [Forms]![YourFormName]![YourTextBoxName] & "*".

Lastly, on the form, I right-clicked on the button I created, selected Build Event - Code Builder and put in the following for the code:

Private Sub YourCommandButtonName_Click()

Me.Requery

End Sub

This just tells the button on the form to resend the query, and after clicking it re-runs your query with the info that is in the text box you named above. Good luck!
 

Users who are viewing this thread

Back
Top Bottom