on KEYDOWN ON SET FOCUS

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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

Thanks It's GREAT!

But the code here makes a little error on response : that's when to press
'ctrl' and 'end' it works, while to press only 'end' it's also making the
same response as to to press both key 'ctrl' and 'end' but while pressing
only key 'ctrl' it won't response to the commands, that's okey. So, Could any
change to make only press both keys response not only key 'end' as the same
both keys . I have put the 'and' but it seems won't do anything to do with
it.

Private Sub Text0_KeyDown(KeyCode As Integer, Shift As Integer)
'Debug.Print "KeyDown: ", KeyCode, "Ctrl ? ", acCtrlMask = (acCtrlMask And
Shift)
If KeyCode = 35 And 17 Then

MsgBox ("YOUR PRESS CTRL and END")
'you can try press only key end works the same
End If
End Sub
 
Hi,



A single value cannot be at the same time equal to 35 and to 17. If it is
35, it will be equal to 35, not to 17.

Use


(35 = KeyCode) And (acCtrlMask = (acCtrlMask And Shift))



Hoping it may help
Vanderghast, Access MVP
 
Back
Top