A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

LIKE search help needed



 
 
Thread Tools Display Modes
  #1  
Old June 4th, 2010, 03:32 PM posted to microsoft.public.access
Song[_4_]
external usenet poster
 
Posts: 43
Default 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  
Old June 4th, 2010, 03:56 PM posted to microsoft.public.access
Tom van Stiphout[_2_]
external usenet poster
 
Posts: 1,653
Default 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  
Old June 4th, 2010, 04:15 PM posted to microsoft.public.access
Song[_4_]
external usenet poster
 
Posts: 43
Default 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  
Old June 4th, 2010, 04:43 PM posted to microsoft.public.access
KenSheridan via AccessMonster.com
external usenet poster
 
Posts: 1,610
Default 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  
Old June 4th, 2010, 04:52 PM posted to microsoft.public.access
Song[_4_]
external usenet poster
 
Posts: 43
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 07:57 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.