Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > Database and Reporting > Database Search


Reply
 
Thread Tools Display Modes
  #1  
Old 05-07-2002, 03:12 PM
Hiren
Guest
 
Posts: n/a
Default Database Search


Hi all,

Code:
Private Sub searchGo_Click()
mmdbChar.Recordset.FindFirst "FirstName = '" + mmSearch.Text + "'"
End Sub
I'm using the following code to search the table mmdbChar and in the field FirstName to find mmsearch.text.

<Question>
However this is not what i really wanted, what i would like to have would be a method to search all of the fields for a keyword.
</Question>

I've seen these Select statements but i have no clue of how to implement them. I would prefer that the answer doesn't have select statements in them becuase that is out of the scope of my little project.

Thanx guys.
Reply With Quote
  #2  
Old 05-07-2002, 04:05 PM
Phoebe
Guest
 
Posts: n/a
Default

'rs is the recordset
'it will search all the fields in all the records for "text I want to find"

<code>
For intCounter = 0 To rs.RecordCount - 1
For intAnotherCounter = 0 To rs.Fields.Count - 1
If CStr(Trim(rs.Fields.Item(intAnotherCounter))) = "text I want to find" Then
'Do something with this record
End If
Next
rs.MoveNext
Next
</code>
Reply With Quote
  #3  
Old 05-08-2002, 07:19 AM
Hiren
Guest
 
Posts: n/a
Default

I keep getting invalid use of Null here

CStr(Trim(mmdbHouse.Recordset.Fields.Item(intAnotherCounter)))

it is probably becuase the particular field is empty, how would i get around this or handle it?
Reply With Quote
  #4  
Old 05-08-2002, 07:45 AM
Thinker Thinker is offline
Iron-Fisted Programmer

Retired Moderator
* Guru *
 
Join Date: Jul 2001
Location: Fayetteville Arkansas USA
Posts: 18,127
Default

The CStr() function is doing nothing here as Trim must already
be working with a string. Try...
Code:
Trim(mmdbHouse.Recordset.Fields.Item(intAnotherCounter) & "")
__________________
Posting Guidelines
Reply With Quote
  #5  
Old 05-08-2002, 08:23 AM
Phoebe
Guest
 
Posts: n/a
Default

I should have written:

If isnull(rs.fields.item(intCounter)) = FALSE then
If ucase(trim(cstr(rs.Fields.item(intCounter)))) = "TEXT I WANT TO FIND" then
'Do something
End if
End if
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->