I'm working on an Access database that should be used in a French speaking country. In order to avoid that the user must type all accents of search terms correct, I have added a string with replace commands to allow easy recovery of the searched items.
I use a split form as search form. In the header of the form a textbox is placed where the usere enters his search as he/she types.
The following code works fine (can be used to type space between words)
Code: Select all
Private Sub txt_filter_Change()
'--------------------------------------------
'CODE frm_Select_Patient - 001
'--------------------------------------------
' If the textbox is cleared, clear the form filter.
If Nz(Me.txt_Filter.Text) = "" Then
Me.Form.Filter = ""
Me.FilterOn = False
Else ' If a partial value is typed, filter for a partial name match.
Me.Form.Filter = "[Full_Name] Like '*" & _
Replace(Me.txt_Filter.Text, "'", "''") & "*'"
Me.FilterOn = True
End If
' Move the cursor to the end of the box.
Me.txt_Filter.SetFocus
Me.txt_Filter.SelStart = Len(Me.txt_Filter.Text)
End Sub
Code: Select all
Private Sub txt_filter_Change()
'--------------------------------------------
'CODE frm_Select_Anamnèse - 002
'--------------------------------------------
Dim strSansAccents As String
' If the box is cleared, clear the form filter.
If Nz(Me.txt_Filter.Text) = "" Then
Me.Form.Filter = ""
Me.FilterOn = False
Else ' If a partial value is typed, filter for a partial company name match.
'remove all accents and compare with the "maladie" without accents (so that the user does not have to care about accents)
strSansAccents = Replace(Replace(Replace(Replace(Replace(Replace(Me.txt_Filter.Text, "é", "e"), "ë", "e"), "è", "e"), "ê", "e"), "ï", "i"), "à", "a")
Me.Form.Filter = "[MaladieSansAccents] Like '*" & _
Replace(strSansAccents, "'", "''") & "*'"
Me.FilterOn = True
End If
' Move the cursor to the end of the box.
Me.txt_Filter.SetFocus
Me.txt_Filter.SelStart = Len(Me.txt_Filter.Text)
End Sub
Kind regards,
Orion