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

recordset problem when using *text* operator

Status
Not open for further replies.

yoyo138

Technical User
Oct 13, 2006
1
US
hello,

i am trying to populate a listbox with an sqlstring while at the same time using a recordset (using same sqlstring) to tally-up values from a particular field.

as of right now, the listbox populates w/o error, but when i [try to] initialize my recordset, nothing happens (except eof=true)
it seems that anytime i use string/text for my search condition, recordcount is 0 (even though my listbox displays proper output). if i use numeric data for search, the recordset initializes properly and i get no errors.

if anyone has any suggestions with this that would be great.

here is a sample of my code:
Dim rs As New ADODB.Recordset
dim strSQL as string

strSQL = "SELECT * FROM Clients WHERE Notes Like " & Chr(34) & "something" & Chr(34)
lstBox.RowSource = strSQL
rs.Open strSQL, CurrentProject.Connection, adOpenKeyset, adLockOptimistic

If Not rs.EOF Then
msgbox rs.RecordCount
End If

rs.Close

Set rs = Nothing

Thanks,
DC
 
Hmmm, if that happens your RecordCount should show -1

Try:
Code:
If Not rs.EOF Then
    [red]rs.MoveLast[/red]
    msgbox rs.RecordCount
End If

HTH

---- Andy
 
Try this:
Code:
strSQL = "SELECT * FROM Clients WHERE Notes Like '" & "something" & "'"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
I think you are missing the wildcard character after your search term.
 
As you use ADO I suggest single quotes for text literal and % as wildcar.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 

This "something" may be:
Code:
something = "'James%'"

---- Andy
 
This may be of some help:

thread222-889231

Swi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top