?
Solved

How to Trap <Enter> key in DateTime Picker

Posted on 2003-03-31
4
Medium Priority
?
1,263 Views
Last Modified: 2012-06-27
Hi,

I'm wondering how a DateTime Picker control can trap a <Enter> key. I want a DateTime Picker control can response to <Enter> key so that it can move current focus to another control (has same effect as pressing <Tab> key).

In the KeyPress event of DateTime picker I do this:

 if (KeyAscii = 13) then
   SendKeys "{Tab}"
   KeyAscii = 0
 end if

This code successfully run on TextBox & ComboBox control, but it fails on DateTime picker control. Any ideas?

Thanks in advance

MI
0
Comment
Question by:MiBlg
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 53

Expert Comment

by:Ryan Chong
ID: 8243685
Try the KeyDown event?
0
 
LVL 11

Expert Comment

by:supunr
ID: 8243855
Private Sub DTPicker1_KeyUp(KeyCode As Integer, Shift As Integer)
If (KeyCode = 13) Then
  SendKeys "{Tab}"
  KeyCode = 0
End If
End Sub
0
 

Accepted Solution

by:
MickyMc earned 300 total points
ID: 8243921
Close chap... try this ... in the KeyDown event. You want to process the Key before the control does so chat it in the Keydown. All the best...Mick

Private Sub dtpDate_KeyDown(KeyCode As Integer, Shift As Integer)
   If (KeyCode = vbKeyReturn) Then
     SendKeys "{Tab}"
     KeyCode = 0
   End If
End Sub
0
 
LVL 6

Expert Comment

by:VK
ID: 8252634
hello MiBlg !

How about centralisation of your chr(13) to chr(9)- code ?

If you have a DtPicker you have also a form, say Form1.

Suggestion:

Form1.KeyPreview=True

Private sub Form1_Keydown (KeyCode As Integer, Shift As Integer)
  If (KeyCode = vbKeyReturn) Then
    SendKeys "{Tab}"
    KeyCode = 0
  End If
end sub

V.K.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month15 days, 6 hours left to enroll

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question