Re: on KEYDOWN ON SET FOCUS

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Hi,



Use something like:
=======================
Option Compare Database
Option Explicit

Private Sub Text0_KeyDown(KeyCode As Integer, Shift As Integer)
Debug.Print "KeyDown: ", KeyCode, "Ctrl ? ", acCtrlMask = (acCtrlMask
And Shift)
End Sub

Private Sub Text0_KeyPress(KeyAscii As Integer)
Debug.Print "KeyPress: ", KeyAscii
End Sub

Private Sub Text0_KeyUp(KeyCode As Integer, Shift As Integer)
Debug.Print "KeyUp: ", KeyCode, "Ctrl ? ", acCtrlMask = (acCtrlMask And
Shift)
End Sub
========================


and you will observe that Home key generates a KeyDown and a KeyUp, but not
a KeyPress, with 36=KeyCode.

To check the Control or Alternate key, use the relevant Mask as
illustrated, with the second argument send to the event procedure handler.



Hoping it may help,
Vanderghast, Access MVP




"ooxx" <ooxx@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:DDEBF45D-922D-4D04-AB27-904229343E0E@xxxxxxxxxxxxxxxx
> THANKS YOUR ADVICEs
> Everything OKEY now,
> But Do you know what 's the keycode of 'end' and 'home'?
>
> And if to use the combination 'alt', code 18, with for example code 38 so
> what should the code be if for example we have shift,code shift =1 with
> code
> 39 will only be like ,,,,
> select case keycode
> case 39 and shift =1
> .........
> .........
> case else
> end select
> what would be 'ALT' and combination with code 39 be?
>
> Thanks
>
>
> "Michel Walsh" wrote:
>
>> Hi,
>>
>>
>> If the control is bound to a field and that the actual data does not
>> pass the field validations (like not allowing NULL, not allowing a
>> negative
>> value, etc.), Access will not like to let you leave the control with its
>> illegal data in it.
>>
>> If you are in a context where you can leave the control, then, no
>> need
>> to use special code, try
>>
>> Me.ControlName.SetFocus
>>
>>
>> in VBA code (which I assume is the environment where your problem arise).
>>
>>
>> Hoping it may help,
>> Vanderghast, Access MVP
>>
>>
>> "ooxx" <ooxx@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
>> news:24D73FED-6E21-4521-832A-AB15940B0417@xxxxxxxxxxxxxxxx
>> > JAMWS;
>> >
>> > OH ley,,, leg leg ..
>> > The question is when the control textbox on keydown .. . some codes
>> > can
>> > make the setfocus when typing speicial keycodes like 39 . while on the
>> > other
>> > textbox using the same won't make the same response. MS ACCESS have
>> > errors .
>> >
>> > OKEY if the setfocus won't response can we make it exit to leave to
>> > another
>> > tab order textbox.
>> > WOW WOPP WOPP
>> > THANKS
>>
>>
>>


.



Relevant Pages

  • Re: Repeat data input within forms, Access 2003
    ... that sets the default to the current value in the control. ... Private Sub Form_AfterUpdate ... Access MVP 2002-2005, 2007 ... of form text boxes & combo boxes. ...
    (microsoft.public.access.gettingstarted)
  • Re: ComboBox wont display what is selected...
    ... I'd change your AfterUpdate event procedure code to use the RecordsetClone ... ' Find the record that matches the control. ... <MS ACCESS MVP> ... Private Sub Form_Current ...
    (microsoft.public.access.formscoding)
  • Re: ComboBox wont display what is selected...
    ... ' Find the record that matches the control. ... "Ken Snell " wrote: ... Private Sub cboRenterLast_AfterUpdate ... <MS ACCESS MVP> ...
    (microsoft.public.access.formscoding)
  • Re: What control for retaining last entered data
    ... >>Properties window. ... >><MS ACCESS MVP> ... >>>>Private Sub cboBoxName_AfterUpdate ... then a control to save the record and ...
    (microsoft.public.access.forms)
  • RE: Special Effect annoying reset delay
    ... Reset it in the mouse move event of the other control. ... Private Sub imgRefresh_MouseMove(Button As Integer, Shift As Integer, X As ...
    (microsoft.public.access.formscoding)