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

using Wild Card for ADO recordset Find in Visual Basic to a SQL 2000

Status
Not open for further replies.

mgardiner

Programmer
Jun 28, 2001
22
US
I am trying to run a Find on a ADO recordset using
an SQL syntax for the Find.
I need to run for a WildCard Character.
here is my code.
----------------------------------------------------------------

Dim adoQuoteRS As Recordset
'create a recordset to search on
Dim strsql As String
Set adoQuoteRS = New Recordset
strsql = "SELECT tblQuotes.*, tblQuoteLog.*, tblProjects.* " & _
"FROM tblProjects " & _
"INNER JOIN tblQuotes ON tblProjects.ProjectsID = tblQuotes.ProjectID " & _
"INNER JOIN tblQuoteLog ON tblQuotes.QuoteID = tblQuoteLog.QuoteID"

adoQuoteRS.Open strsql, g_objConn, adOpenStatic

If FindLookIn = "QuotationNo" Then
'If FindLookIn = "Entire Database" Then
With adoQuoteRS
.MoveFirst
'.Find (FindLookIn & "= '" & findvalue & "'")
.Find ("QuotationNo = '%10881'")
'WHERE (QuotationNo LIKE '%10881')
If .BOF Then
MsgBox "Matching Record not Found"
End If
End With
End If

adoQuoteRS.Close
---------------------------------------------------------------

I cannot get VB to accept the LIKE as valid If I just look for the
entire value then I can find it with out using a wildcard character.
any help would be appreciated.

Also when I open my recordset in dynamic mode I get a recordcount of -1 ????
 
Hi there,
I don't know much about VB but try to use
.Find ("INSTR(QuotationNo,'10881',1)")

I don't know if it helps you
 
Thanks for your quick response.
This uses a VBA style string search.
I tried it with my recordset .find and it didn't work.
Thanks for all your help though.
Morgan
 
Hi,

Try replacing the "=" sign with a LIKE.

.Find ("QuotationNo LIKE '%10881'")

This might do the trick

Randy : )
 
Thanks RJ5
I tried the % in different places and came up with mixed results.
I don't know why yet but I think I can work around it.

.find ("QuotationNO LIKE '%10881%'")
Works fine

.find ("QuotationNO LIKE '10881%'")
Works fine to find the number and anything behind the text

.find ("QuotationNO LIKE '%10881'")
gives me a Error 3001 arguments are of the wrong type.

I don't know why this would be.
but %10881% will have to work for me for right now until someone can
explain it to me.
Thanks Morgan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top