If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
LIKE search help needed
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 |
#2
|
|||
|
|||
LIKE search help needed
On Fri, 4 Jun 2010 07:32:48 -0700 (PDT), Song
wrote: You're missing a space and you have a spurius "=". It should be: strCriteria = "PODetail.ItemDescription Like *" & txtSearch & "*" -Tom. Microsoft Access MVP 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 |
#3
|
|||
|
|||
LIKE search help needed
Thank you for fast reply. I changed the code but it still has no
result. strCriteria = "PODetail.ItemDescription Like *" & txtSearch & "*" On Jun 4, 7:56*am, Tom van Stiphout wrote: On Fri, 4 Jun 2010 07:32:48 -0700 (PDT), Song wrote: You're missing a space and you have a spurius "=". It should be: *strCriteria = "PODetail.ItemDescription Like *" & txtSearch & "*" -Tom. Microsoft Access MVP 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- Hide quoted text - - Show quoted text - |
#4
|
|||
|
|||
LIKE search help needed
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 Song wrote: 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 - -- Message posted via http://www.accessmonster.com |
#5
|
|||
|
|||
LIKE search help needed
On Jun 4, 8:43*am, "KenSheridan via AccessMonster.com" u51882@uwe
wrote: 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 Song wrote: 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 - -- Message posted viahttp://www.accessmonster.com Thanks. strCriteria = "PODetail.ItemDescription Like ""*" & txtSearch & "*""" works perfect! |
Thread Tools | |
Display Modes | |
|
|