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

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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 ..
 
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
 
Back
Top