Results 1 to 3 of 3
  1. #1
    MustMus is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Sep 2018
    Posts
    1

    Search Box in form_Two languages data to be searched for

    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

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,646
    You might get more help if you post code between CODE tags so it retains indentation and readability. Can edit your post.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Minty is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,144
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 08-21-2018, 03:11 PM
  2. Email to Drifferent languages out of access
    By Rusty11 in forum Access
    Replies: 2
    Last Post: 05-18-2012, 12:18 AM
  3. Decimal seperator between different languages
    By seshan in forum Programming
    Replies: 3
    Last Post: 01-31-2010, 03:03 PM
  4. Replies: 1
    Last Post: 09-29-2009, 04:34 AM
  5. Please help w/ simple languages db
    By TalentNation.net in forum Database Design
    Replies: 0
    Last Post: 01-23-2009, 09:11 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums