Search Box in form_Two languages data to be searched for (1 Viewer)

Mustmys

New member
Local time
Yesterday, 18:01
Joined
Sep 10, 2018
Messages
1
Dears,, hope all is doing well

I have a data of customers Last name, (The last name is in both English and Arabic language, so it is mixed)

I have added a search box to search for records in a form
the problem is that I'm not able to switch between the two languages because of the keycodes, I can only search either for Arabic or English name.

L letter key code is 76 which is the same Arabic key for letter ( م ) which is Microsoft keycode of 227
so when I press L key it will give only L
but when using this code (If KeyCode = 76 Then KeyCode = 227) I will get the Arabic letter but will lose L letter.
any suggestions please? how can I can change search language in such case? thanks
below is the VBA code:


Select Case KeyCode
Case 122
If Shift <> 4 Then
KeyCode = 0
End If
Case vbKeyRight, vbKeyLeft
Case 48 To 57, 65 To 90, 645
If KeyCode = 76 Then KeyCode = 227
If KeyCode = 87 Then KeyCode = 213
Set ctl = Screen.ActiveControl
fldName = ctl.Name
If fldName <> LastFld Then
srchval = ""
End If
LastFld = fldName
srchval = srchval & Chr(KeyCode)
KeyCode = 0
If fldName = "Address" Then
srchcrit = "[" & fldName & "] Like '*" & srchval & "*'"
Else
srchcrit = "[" & fldName & "] Like '" & srchval & "*'"
End If
Set rst = Me.RecordsetClone
rst.FindFirst srchcrit
If rst.NoMatch Then
MsgBox (" Record not found! ")
Else
Me.Bookmark = rst.Bookmark
End If
rst.Close
Case 107, 187
If srchval = "" Then
KeyCode = 0
Exit Sub
End If
Set ctl = Screen.ActiveControl
fldName = ctl.Name
KeyCode = 0
Set rst = Me.RecordsetClone
rst.Bookmark = Me.Bookmark
rst.FindNext srchcrit
If rst.NoMatch Then
MsgBox (" Record not found! ")
Else
Me.Bookmark = rst.Bookmark
End If
rst.Close
Case 109, 189
If srchval = "" Then
KeyCode = 0
Exit Sub
End If
Set ctl = Screen.ActiveControl
fldName = ctl.Name
KeyCode = 0
Set rst = Me.RecordsetClone
rst.Bookmark = Me.Bookmark
rst.FindPrevious srchcrit
If rst.NoMatch Then
MsgBox (" Record not found! ")
Else
Me.Bookmark = rst.Bookmark
End If
rst.Close
Case 27
KeyCode = 0
srchval = ""
Case Else
KeyCode = 0
End Select
Exit Sub
 

JHB

Have been here a while
Local time
Today, 02:01
Joined
Jun 17, 2012
Messages
7,732
Maybe it's because I can not see the problem, but I would built two search strings, one for English and one for Arabic.
Could you show some Last name samples.

Please show the entire code and also explain your code.
And as CJ_London says, use code tags.
 

Users who are viewing this thread

Top Bottom