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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I want to add a Search button to my VB 6.0 form

Status
Not open for further replies.

PleaseGiveHelp

Programmer
Oct 29, 2002
131
US
I have created an application that consists of 4 text boxes displaying data from database along with a data grid that displays the results in the text boxes, yet in more detail. My database is a SQL Server database. I am able to add data, delete data and modify data using this form. However I am having difficulties attempting to search. It is very annoying to have to click on the arrows to go to the first, last, previous or next record. I want to add a search button so that the user will be able to jump ahead to the record that is searched. I don't even know where to start. Please help. For your purposes, lets say the text boxes are: account number, Name, company and phone number. I'd like to be able to search using one or any of the text fields.
 
Put a WHERE clause in yopur SELECT statement. If you had a search textbox txtSearch and a Command button cmdGo you could use something like this in the cmdGo Click Event:
[tt]
If Len(txtSearch.Text) > 0 Then
strSQL = "Select * from tblWhatever Where fldName Like '" & txtSearch.Text & "%'[/tt

Then use strSQL to requery your database, using the returned recordset to populate your grid/textboxes or whatever
________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top