Full Version: Trapping Date Picker event
UtterAccess Forums > Microsoft® Access > Access Forms
dhapp
I am using the Date Picker that comes with v2007
would like to move the focus to another control when the user chooses either a date or 'Today'. Currently when the user makes a choice the appropriate date shows up in the control and the cursor is at the end of the date in that control.
How do I trap that event so that when the date is chosen the cursor moves to another control?
theDBguy
Hi,
Have you tried the AfterUpdate event of the date control?
Hope that helps...
dhapp
Yup - tried that before posting.
When you click a choice in the date picker the date is inserted in the control and the cursor sits after the last character in the date. If you then enter a return, tab, or click then the AfterUpdate event will launch.
It appears to me that I would need to modify the code that places the date into the control.
theDBguy
I see. I'm not sure how you can modify the date picker code but here's a possible workaround:
Private Sub YourDateFieldControl_Change()
If IsDate(Me.YourDateFieldControl.Text) Then
Me.OtherFormControl.SetFocus
End If
End Sub
Hope that helps...
vtd
>>It appears to me that I would need to modify the code that places the date into the control.
would expect so... Have you checked the code for the DateTimePicker_Updated Event?
I would expect the code to assign the date/time value to the (TextBox) Control is called by this Event and you should be able to modify the code to move the Focus after assigning the date/time value.
dhapp
Van,
Thanks
You wrote: "Have you checked the code for the DateTimePicker_Updated Event? "
Where is the DTP_Update event code located??
Oused the suggestion of DBguy, to put the code in the OnChange event of the Date control, and that does works, but I would also like to know where to find the code for the DateTimePicker.
theDBguy
Hi Doug,
Glad to hear the code works. I would also be interested to see Van's reply on how to modify the code for the DatePicker in case I run into the same situation in the future. Good luck with your project.
dhapp
DBguy,
The OnChange event got me about halfway to a good solution.
A little background on the form that I am working on:
There are four controls (in the order that they are used): a date (uses the DatePicker), two combo boxes and a control that takes a numerical value.
I have set up the OnGotFocus event of each combo boxes to .Dropdown and the AfterUpdate event of each control to move it to the next control.
So entering the date should move focus to the first dropdown control, which will dropdown the list. When the user click the choice the focus moves to the second combo box, which immediately drops down. When the user makes that choice the focus move to the last control to get the numerical value.
If I use the keyboard to enter the date and hit Tab or Enter the focus moves to the first combo box, which drops down. A single clicking of a choice in the dropdown list will put that choice in the box and move focus to the second combo box, which will drop down showing the choices. A single click of a choice in the list will accept the choice and move to the last control.
If I use the DatePicker (with or without the OnChange event code) to choose the date then I see a different action in the first combo box:
1. If I use the DatePicker followed by Tab or Enter, the focus moves to the first combo box, which drops down, but I need to click once to highlight a choice and once more to select it into the control, then the focus moves to the next combo box.
2. If I use the DatePicker with the OnChange code the focus moves immediately after the making the selection in the date picker and the combo box does drop down, but it requires one click in the list to highlight the choice and another click to select it into the control. The focus moves to the second combo box.

Moving from the first combo box to the second combo box works as it should i.e. the box get focus, drops down and a single click make the choice and moves to the next control.
I would like to not have to use that extra click.
Any ideas iconfused.gif
vtd
Can you see the "On Change" row on the "Event" tab of the Properties window of the DateTimePicker Control?
If you have any code that uses this event, you should see something in this row, either as "[Event Procedure]" or some custom UDF.
theDBguy
Hi Doug,
If you haven't posted a small copy of your db with test data, now might be a good time to do it if you can.
RLG
I am having the same problem exactly and have been trying to solve it for a week or so.
The built-in DatePicker in A2007 seems not to have any properties that you can get at. And when I use the OnChange event to go to next control, the date in the textbox has not been updated and remains as Null.
More help please!
Richard
theDBguy
Hi Richard,
welcome2UA.gif
May I suggest that you actually post a new topic with your question so that others who may not be following this thread at all might be able to offer their help to you.
Just my 2 cents...
RLG
Thanks for the advice - will do!
ichard
theDBguy
Good luck!
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.