Date Picker - requires Tab to move cursor for completion

Rx_

Nothing In Moderation
Local time
Today, 00:43
Joined
Oct 22, 2009
Messages
2,803
Access 2010 The Date picker leaves the cursor on the right hand side of the date. While there, neither the Tab or Mouse click will move to the next field.
With the cursor on the right-hand side, a Tab will move the cursor to the left hand side. Then either a Tab or Mouse click will move to the next field. In other words, it takes a <Tab><Tab> to move to the Type field.

A couple of things:
The Cancle Update is called until all three required fields are completed. Can't update the form's recordset until all 3 * required fields are completed. The Form Preview is True.

A VBA solution is acceptable.
Image attached - Add New Record, choose date with Date Picker, the cursor is on the very right-handed side.
 

Attachments

  • Date Picker Stuck on Right until Tab used.gif
    Date Picker Stuck on Right until Tab used.gif
    30.9 KB · Views: 317
On the Change event of the textbox:

1. Test the value if it's a valid date - use IsDate()
2. If it is, set the Text to the Value of the textbox. Simple assignment.
3. Move the cursor to the end of the text - use SelStart
 
That did move the cursor to the left side. But, the stubborn DatePicker won't yeild until a TAB.
Hesitant to use a sendkey TAB because I read that it's timing might not be instant. The users will complain about having to Tab twice.

In step 3, tried with no luck to set the .ShowDatePicker property to False - then refresh the control.


Private Sub txtDateSubmitted_Change()
'1. Test the value if it's a valid date - use IsDate()
'2. If it is, set the Text to the Value of the textbox. Simple assignment.
'3. Move the cursor to the end of the text - use SelStart
If IsDate(Me.txtDateSubmitted.Text) Then
Me.txtDateSubmitted.Value = Me.txtDateSubmitted.Text
Me.ActiveControl.SelStart = 0
End If
End Sub
 

Attachments

  • Date Picker Stuck on Right until Tab used 2.gif
    Date Picker Stuck on Right until Tab used 2.gif
    6.8 KB · Views: 229
Me.txtDateSubmitted.SelStart = Len(Me.txtDateSubmitted)
 
Thanks. That just put the cursor back to look like the first screen. The DatePicker still there. If a mouse click on the next field would close the DatePicker, that would be OK. But, while the DatePicker is showing all events but Tab are held up.

Setting the DatePicker property to false doesn't work either.
 
So you just want the DatePicker to disappear?

* Perform steps 1 and 2 (from previous post)
* SetFocus to a transparent button on your form
* Set Focus back to your textbox
* Perform step 3 (from previous post)
 
Thank you very much. With the Date picker showing, a date can be selected. But now it only takes a single Tab to move to the next field. Also, a mouse click can now be used to move to a required field (red *)
Instead of a transparent textbox (great suggestion) an existing text box was used. An object loop reading a tag enables and disables controls when the Add New state is true.

Code:
Private Sub txtDateSubmitted_Change()
'1. Test the value if it's a valid date - use IsDate()
'2. If it is, set the Text to the Value of the textbox. Simple assignment.
'3. Move focus to another control, then back to this control
If IsDate(Me.txtDateSubmitted.Text) Then
    Me.txtDateSubmitted.Value = Me.txtDateSubmitted.Text
        Me.txtState_Sub_No.Enabled = True ' AddNew State - object loop disabled this and others
        Me.txtState_Sub_No.Locked = False
    Me.txtState_Sub_No.SetFocus           ' This took the focus off txtDateSumbitted PickDate icon
        Me.txtState_Sub_No.Enabled = False  ' Set text box back to AddNew state
        Me.txtState_Sub_No.Locked = True
    Me.txtDateSubmitted.SetFocus           ' focus back to this control
End If
 '  The Date Submitted now can use mouse or single tab to highlight next required field
End Sub

Here is what I consider a bug in the DatePicker.
1. Access Programmers have no way to directly control the pesky thing
2. With this code, if a user attempts to type in a date (e.g. 2/22/2010)
while the DatePicker is visible - at 2/2 - Access autocompletes 2/2/2012 where 2012 is the Current Year.
So, the Date picker being visible assist the user to type in the wrong date.

So, if the DatePicker object class exposed some properties, the number 2 could be solved with a little code.

B.T.W. This image shows the Date Picker visible after the focus left and was returned. From this point - either a single Tab or a mouse click will take the user to the next field. Evidently Microsoft is very proud of it and wants to show it off. :D

Thanks again! This will really help.
 

Attachments

  • Date Picker Stuck on Right until Tab used 3.gif
    Date Picker Stuck on Right until Tab used 3.gif
    11.5 KB · Views: 197
Last edited:
Good work Rx!

It would be interesting to see this behaviour if you have time to upload a test db that replicates this.
 
Howzit

I have access 2010 and I can confirm that what Rx is saying does occur - you need to tab away from the text box for the date to be returned. MS have removed the old calendar.ocx active X control and replaced it with the datepicker control
 
Yes I know that but that's not what the problem is. Rx is saying that he needs to Tab twice to get out of the textbox. By the way, it was removed from 2007.
 
They are relocating my office over this weekend in between my data migration and the upcoming move Access back-end to SQL Server. The overtime is wonderful!
I will try to come back to provide a simple example.
Also remember, I am canceling the update until three required fields are populated.
That may or may not be part of this interesting situation.
Thanks again for the help. It seems like the little things take the most time. But, it is the visible little things the customer sees.
 

Users who are viewing this thread

Back
Top Bottom