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
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