|
|||||||
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
#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 |
|
|
|
|
|
#2 |
|
Professional gadfly
|
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. |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|