MartyConnelly
martyconnelly at shaw.ca
Thu Jan 4 14:11:44 CST 2007
Just some other odd info for international apps and keyboards. Handy if you need fully bilingual apps where a form has to accept two languages If you are using multiple language keyboards on one machine, here is some code to sense what OS language keyboard is active and to switch back and forth between keyboard types. Rather than use Alt Right Shift key to switch back and forth. The other thing you will have to do is switch language keyboards for text input. Using routines like below. I use this for multilanguage input on one form To set these OS keyboards Control Panel --> Regional& Language --> Language --> Details --> Settings With WinXP keyboards you want to put something in each textbox tag property to indicate language "Arabic" or "French" 'Really rough test code to change keyboards as you 'shift to a new text box requiring a different language. Sub ShiftToLanguage() 'use the following code inside form or focused window or textbox 'to simulate the Alt RightShift = key combination: ' then press and then release the AltRight RightShift key 'order of pressing important keybd_event VK_RSHIFT, 0, 0, 0 keybd_event VK_RMENU, 0, 0, 0 keybd_event VK_RMENU, 0, KEYEVENTF_KEYUP, 0 'weird things happen if you don't up the shiftkey looks like capslock 'has been left on keybd_event VK_RSHIFT, 0, KEYEVENTF_KEYUP, 0 'line below needed for Access97 ' keybd_event VK_RMENU, 0, KEYEVENTF_KEYUP, 0 Debug.Print "Right Shift" DoEvents End Sub or 'Private Const VK_LMENU = &HA4 Private Const VK_MENU = &H12 ' Virtual Keycode for the Alt key Private Const KEYEVENTF_KEYUP = &H2 'Private Declare Function ActivateKeyboardLayout Lib "user32" ( _ ' ByVal HKL As Long, ByVal Flags As Long) As Long 'Private Declare Function GetKeyboardLayout Lib "user32" (ByVal dwLayout As Long) As Long Private Declare Function GetKeyboardLayoutName Lib "user32" Alias "GetKeyboardLayoutNameA" (ByVal pwszKLID As String) As Long Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, _ ByVal bScan As Byte, ByVal dwflags As Long, ByVal dwExtraInfo As Long) Private Sub Text0_GotFocus() ShiftToLanguageBack Me.Text0.SetFocus Curr_Frm_Control keybd_event VK_MENU, 0, 0, 0 keybd_event VK_MENU, 0, KEYEVENTF_KEYUP, 0 ' keybd_event VK_RMENU, 0, KEYEVENTF_KEYUP, 0 DoEvents Debug.Print "here" End Sub Private Sub Text2_GotFocus() ShiftToLanguage Me.Text2.SetFocus Curr_Frm_Control keybd_event VK_MENU, 0, 0, 0 keybd_event VK_MENU, 0, KEYEVENTF_KEYUP, 0 'keybd_event VK_RMENU, 0, KEYEVENTF_KEYUP, 0 DoEvents Debug.Print "Here2" End Sub Function Curr_Frm_Control() Dim ctlCC As Control Dim frm As Form Dim strCurrent_Buffer As String Dim lret As Long fCheckControlType 'Retrieves current name of the active keyboard layout lret = GetKeyboardLayoutName(strCurrent_Buffer) Debug.Print strCurrent_Buffer ' Set frm = Screen.ActiveForm ' Debug.Print frm.Name Set ctlCC = Screen.ActiveControl Curr_Frm_Control = ctlCC.Name Debug.Print Curr_Frm_Control End Function Private Function fCheckControlType() Dim ctl As Control Set ctl = Me.ActiveControl Debug.Print ctl.ControlType 'Debug.Print ctl.Form.Name End Function Beach Access Software wrote: >Fortunately the language table is in the front end. That's so each user can >select their own language. > >Rocky > >-----Original Message----- >From: accessd-bounces at databaseadvisors.com >[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Hale, Jim >Sent: Thursday, January 04, 2007 8:58 AM >To: 'Access Developers discussion and problem solving' >Subject: Re: [AccessD] A Question of Timing > >If you are going to use seek on back end tables you will need to set the >database variable using a function like WhichDB. >HTH >Jim Hale > >Function CurrYear() As Integer >Dim strTable As String, db As Database, rs As Recordset >'find current month in periods table > strTable = "tblPeriods" > Set db = WhichDB(strTable) > Set rs = db.OpenRecordset(strTable, dbOpenTable) > 'find record with the current year > rs.Index = "fldStatus" > rs.Seek "=", "B" > CurrYear = rs.Fields("fldYear") > > >Function WhichDB(strTableName As String) As Database >Dim dbpath$, SourceTable$, dbTest As Database > >On Error GoTo whichDB_ERR >Set dbTest = DBEngine(0)(0) >dbpath = Mid(dbTest(strTableName).Connect, InStr(1, >dbTest(strTableName).Connect, "=") + 1) >If dbpath = "" Then > Set dbTest = CurrentDb() >Else > Set dbTest = DBEngine(0).OpenDatabase(dbpath) >End If >Set WhichDB = dbTest >whichDB_EXIT: > > Exit Function > >whichDB_ERR: > MsgBox Err.Description > Resume whichDB_EXIT >End Function > >-----Original Message----- >From: Gustav Brock [mailto:Gustav at cactus.dk] >Sent: Thursday, January 04, 2007 10:08 AM >To: accessd at databaseadvisors.com >Subject: Re: [AccessD] A Question of Timing > > >Hi Rocky > >You could use DAO and the Seek method on this local table if it is indexed >properly. >Seek is extremely fast but the syntax is a bit weird. > >/gustav > > > -- Marty Connelly Victoria, B.C. Canada