Need help using "Like" in a programmatic SQL statement!!

V

Vic

Having a rough time using "Like" in an expression. Compare the following two statements

1) strSQL = "Select * from tblLot Where LotNumber = '20040302002' Order By LotNumber
2) strSQL = "Select * From tblLot Where LotNumber Like '20040302*' Order By LotNumber

When I use the first statement with my data, I get a recordcount of 1 (expected
When I use the second, I get a recordcount of 0 (NOT expected

Here's the rest of the code

Dim rst As ADODB.Recordse
Set rst = New ADODB.Recordse
With rs
.ActiveConnection = CurrentProject.Connectio
.CursorType = adOpenKeyse
.CursorLocation = adUseClien
.LockType = adLockOptimisti
.Open strSQL, Options:=adCmdTex
MsgBox "Number of records: " & .RecordCoun
End Wit

Anone have a clue what I'm doing wrong? Much obliged ..
 
A

Anne Nolan

Try using % instead of * for your wildcard character. Since you are using ADO, I suspect
that your data is in a SQLServer or other non-jet database.

Anne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top