Go Back   PCMech Forums > Help & Discussion > Web Design / Development

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 10-07-2002, 11:42 AM   #1
Member (7 bit)
 
Join Date: Feb 2002
Posts: 67
Search Matches

In Visual Basic I'm trying to search a database for matches to text in a text box on the form. However, the method:

If txtWidth.Text = rsRecordSet("Width").Value Then

Always seems to return false, even if the are hudreds of matches.

I'm definitely searching the whole database as it always moves to the last record. Any ideas what to do?

Thanks in advance,

Keys
skeletonkeys is offline   Reply With Quote
Old 10-07-2002, 12:16 PM   #2
Professional gadfly
 
doctorgonzo's Avatar
 
Join Date: Jan 2002
Location: Minneapolis, MN
Posts: 6,364
Send a message via MSN to doctorgonzo
Unless you have that search function in a loop, that's not going to work. That will only test the current record, so in order to test every record you will have to manually step through the entire recordset. That is very inefficient and slow. Instead, use the recordset's Find method (if you are using ADO; for DAO, use FindFirst, FindNext, etc.).

Here's another thought: what do you want to do with the recordset once you have done the search? If you want to just find the records with that criteria, stepping through with the Find method will work. However, if you want to take the subset of records that match your search criteria and then do something with them, you should use the Filter method instead. To do that, you could use something like this:

rsRecordSet.Filter "Width=" & txtWidth.Text

That would filter the recordset to only include records where values in the Width column equal whatever is in the txtWidth textbox. From there, you could step through the recordset and print out the records, update them, and so forth.
doctorgonzo is offline   Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 12:24 PM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 PL2