Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using KeyPress event with DateTimePicker Control 1

Status
Not open for further replies.

MikeCt

Programmer
Nov 6, 2001
44
US
Hi
I have a form with 2 DateTimePickers controls, DTPicker(1) and DTPicker(2)
I have the procedure below but the pressing of the return key does not trigger the event. If I press a number key the event is triggered. How can I detect if the return key is press if the keyPress event does not work with all the keys?

Private Sub DTPicker_KeyPress(Index As Integer, KeyAscii As Integer)
If Index = 1 Then
If KeyAscii = Asc(vbCrLf) Then DTPicker(2).SetFocus
Else
If KeyAscii = Asc(vbCrLf) Then DTPicker(1).SetFocus
End If
End Sub
 
Set the Forms Keypreview to true

then in each DtPickers KeyPress

Adapt this

If KeyAscii = 13 Then
SendKeys "{TAB}"
KeyAscii = 0

....... what u want
End If


n.b At Developement level SENDKEYS will require a workround Under Windows 7 ... Solutions to this are availabe at Tek Tips

Peter
 
Hi
Setting the form Keypreview to true did not help. The Keypress event was not triggered with the pressing of the
Enter key.

Using the keydown event worked perfect and solved the problem

Thankyou
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top