Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

search botton 2

Status
Not open for further replies.

lmanuelab

Programmer
Dec 30, 2004
39
US
i want to make a search botton in my record so when i want to find a name or number i just type what ever i looking for and it will take me there . how do i do that?
 
One approach would be to put a Combo box on your form.

Use the Wizard and it will walk you through the steps to set up the combo box.

Tom
 
How about right-clicking in a field and entering your search text. You can even enter something like
*Dog*
to find all records with Dog anywhere in the field.

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Put this in the 'on click' property of a search command button in the form. changing the search textbox, nameofForm, table, ID, and field accordingly.

Code:
Private Sub cmdSearch_Click()
Dim strSQL As String, strOrder As String, strwhere As String

strSQL = "SELECT * FROM table"
strwhere = " WHERE"
strOrder = " ORDER BY table.ID;" 'ID is the unique identifier

''searchinfo' is the textbox with the search information
strwhere = strwhere & " (table.field) Like '*" & Me.searchinfo & "*'"

'Pass the SQL to the 'Record Source' of the listbox
Form_nameofForm.RecordSource = strSQL & " " & strwhere & "" & strOrder

Form_nameofForm.Requery
End Sub

Ian M. (UK)

Program Error
Programmers do it one finger at a time!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top