LIKE search help needed

S

Song

1st Case Serial Number search works fine.
2nd Case Item Description Like search does not work. No compiling
error and no runtime error but search does not have result which I
know item is in the table.

Private Sub cboSearch_AfterUpdate()
On Error Resume Next
Dim strCriteria As String
If Len(Me.txtSearch) > 0 Then
Select Case cboSearch
Case "Serial Number"
strCriteria = "PODetail.SerialNumber = '" & txtSearch
& "'"
Case "Item Description"
strCriteria = "PODetail.ItemDescription = Like" & "*"
& txtSearch & "*"
End Select
Me.RecordsetClone.FindFirst (strCriteria)
If Me.RecordsetClone.NoMatch Then
MsgBox "No entry found", vbExclamation, "PO Track Search"
Else
Me.Bookmark = Me.RecordsetClone.Bookmark
End If
End If
Me.txtSearch.SetFocus
End Sub
 
T

Tom van Stiphout

On Fri, 4 Jun 2010 07:32:48 -0700 (PDT), Song <[email protected]>
wrote:

You're missing a space and you have a spurius "=". It should be:
strCriteria = "PODetail.ItemDescription Like *"
& txtSearch & "*"

-Tom.
Microsoft Access MVP
 
S

Song

Thank you for fast reply. I changed the code but it still has no
result.

strCriteria = "PODetail.ItemDescription Like *" & txtSearch & "*"
 
S

Song

You need to wrap the pattern string in literal quotes characters:

strCriteria = "PODetail.ItemDescription Like ""*" & txtSearch & "*"""

A pair of contiguous quotes characters within a string expression is
interpreted as a literal quotes character.

Ken Sheridan
Stafford, England
Thank you for fast reply. I changed the code but it still has no
result.
strCriteria = "PODetail.ItemDescription Like *" & txtSearch & "*"
You're missing a space and you have a spurius "=". It should be:
 strCriteria = "PODetail.ItemDescription Like *"
[quoted text clipped - 31 lines]
- Show quoted text -

Thanks. strCriteria = "PODetail.ItemDescription Like ""*" & txtSearch
& "*"""
works perfect!
 

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

Similar Threads


Top