Full Version: Search names with apostrophe
UtterAccess Forums > MicrosoftŪ Access > Access Forms
Good Morning to all of you and in advance thank you for your help, I have this proc and it is working, but when I try to search the name with an apostrophe (D'ANGELO) does not work. Please I need your help on this matter.
Private Sub cmdSearch_Click()
On Error Resume Next
Dim strSQL As String
Dim strValue As String
'Dim quotes As String
'quotes = Chr(34)

If togAll Then
strSQL = "Select * from Clients "
strSQL = "Select * from Clients Where [" & Me![cboField] & "] "
strValue = Trim(Nz(Me![txtValue]))
Select Case Me![cboSearchType]
Case 1: 'Search in the beginning
strSQL = strSQL & "Like '" & strValue & "*' "
Case 2: 'Search anywhere
'strSQL = strSQL & "Like '*" & strValue & "*' "

End Select
End If
Doug Steele
Check my May, 2004 "Access Answers" column in Pinnacle Publication's "Smart Access". You can download the column (and sample database) for free at Smart Access columns.
Thank you, this works like a charm.
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.