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

Like Operator

Status
Not open for further replies.

Vec

IS-IT--Management
Joined
Jan 29, 2002
Messages
418
Location
US
The code below is what I use to search a fld in a db, but it searches for an exact string. Is there a way to modify this code, or can someone show me a new way to search a db that uses a "LIKE" operator. In other words if you enter "johnso" in the txtSearchLast.Text box, the db will still locate johnson because johnson is LIKE "johnso"

Here is the current code I use:

With frmMain!Data1.Recordset
varBookmark = .Bookmark
.Index = "LastName"
.Seek "=", txtSearchLast.Text

If .NoMatch Then
.Bookmark = varBookmark
End If
End With
-
radium.gif

Looking Toward The Future
 
frmMain.data1.recordset.findfirst "Lastname Like "+chr(34)+txtsearchlast +"*" + chr34
 
Sorry - it should be chr(34) on the end - not chr34
 
Below is what I tried, when I run it I get a syntax error and then it highlights the text I have put red below, what am I doing wrong?
With frmMain.Data1.Recordset.FindFirst "Lastname Like " + Chr(34) + txtSearchLast + "*" + Chr(34)
varBookmark = .Bookmark
.Index = "LastName"
.Seek "=", txtSearchLast.Text

If .NoMatch Then
.Bookmark = varBookmark
End If
End With -
radium.gif

Looking Toward The Future
 
This looks like VB, so use the "&" operator to concatenate strings. Hope it helps...
 
Vec, try this:

Code:
With frmMain.Data1.Recordset

        .FindFirst "Lastname Like '" & txtSearchLast + "%'" 
        varBookmark = .Bookmark
        .Index = "LastName"
        .Seek "=", txtSearchLast.Text

        If .NoMatch Then
           .Bookmark = varBookmark
        End If
End With

 
Vec, try this:

Code:
With frmMain.Data1.Recordset

        .FindFirst "Lastname Like '" & txtSearchLast & "%'" 
        varBookmark = .Bookmark
        .Index = "LastName"
        .Seek "=", txtSearchLast.Text

        If .NoMatch Then
           .Bookmark = varBookmark
        End If
End With

 
It gives the error: "Operation is not supported with this type of object" and then highlights:

.FindFirst "Lastname Like '" & txtSearchLast & "%'" -
radium.gif

Looking Toward The Future
 
I am just using a Data Control from the toolbox, and putting the path in the Database Name of the properties -
radium.gif

Looking Toward The Future
 
Hmm.. I wish I could help you further, but i'm more familiar with ADO.

I'll toy with it however, and if I come up with anything I'll let you know.

Sorry I couldn't be of more help!

s-)

--NipsMG
 
Thanks NipsMG. I hope I can figure it out, I just got back from Chapters, I bought Visual Basic 6.0 Black Book by Steven Holzner

It has everything in it! -
radium.gif

Looking Toward The Future
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top