Selasa, 21 Agustus 2012

[MS_AccessPros] Issue with a string search

 

I have the folling search code:
Dim strFilter As String
Dim bFilter As Boolean

bFilter = False
strFilter = ""
Private Sub RunFilter()
If Nz(Me.cboLastName, "<All>") > "<All>" Then 'LastName
If Len(Nz(strFilter)) > 0 Then strFilter = strFilter & " And "
strFilter = strFilter & "LastName = '" & Me.cboLastName & "'"
bFilter = True
End If

If Nz(Me.cboFirstName, "<All>") > "<All>" Then 'LastName
If Len(Nz(strFilter)) > 0 Then strFilter = strFilter & " And "
strFilter = strFilter & "FirstName = '" & Me.cboFirstName & "'"
bFilter = True
End If

If bFilter Then
Me.sfrmClientList.Form.OrderBy = ""
Me.sfrmClientList.Form.Filter = strFilter
Me.sfrmClientList.Form.FilterOn = True
Else
Me.sfrmClientList.Form.FilterOn = False
End If
End Sub

The issue is when the name contains a single quote it throws an error otherwise it works fine. Can you give me an idea of the issue?

Thanks

Art Lorenzini
Sioux Falls, SD

__._,_.___
Recent Activity:
.

__,_._,___

Tidak ada komentar:

Posting Komentar