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!

How can I use a TextBox to Search through my Database?

Status
Not open for further replies.

Skinsella

Programmer
Feb 20, 2001
23
GB
OK what I have is a simple form that displays a members Name, Address, etc. I've set up an SQL database called "MemberSQL", "TblRecords" is the name of the Table used for this screen. "txtRecordName" is the name of a TextBox which is used at run-time to search for a specific record name. "RecordName" is also the primary key in the table, so once the user searches through the database and, if a record is found, it displays the information contained in that record in other text boxes on the form.
For example the user would type "Fred" in the "RecordName" TextBox, and then if a record is found it displays "txtMemberName", "txtMemberAge", "txtMemberAddress" all of which correspond to a column name in the database. My problems are: How do I search the Database? and
How do I bring up the information, after it has searched, into the corresponding TextBox fields?
I'm using a Data Environment to connect to the SQL database if that helps. Anyone got any simple solutions?
 
I've had experience doing this with ADO. There is a
Code:
find
method for recordsets. You tell the recordset what to look for, how many records to skip, which way to look, and where to start then it points to the first record that meats the criteria. If nothings is found, then it points to the beginning or end of file depending on what direction you're searching. Once the pointer is looking at the record you want, then you just assign the text value of the textboxes to the appropriate field. Something like:
Code:
txtMemberAge.Text = MemberRS("MemberAge").Value
for each text box.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top