Hi guys
I use the following command to show the date picker when a textbox gets focus, which works pretty well.
Code:
Private Sub date_select_GotFocus()'sub to show the date picker automatically when the date cell is selected
RunCommand acCmdShowDatePicker
End Sub
However, the textbox is also the first textbox on the form and hence gets focus on form load, meaning the focus needs to be lost before my above code will run. Ideally, I'd like nothing on the form to have focus on loading, but a quick Google makes me think this is impossible. So I tried to add the following to my form_load() routine but it isn't working, i.e. the datepicker doesn't show (although the focus appears to be set as the little icon appears adjacent to the textbox). Prior to the sample below, the code goes through all of the controls on the form and resets them but I don't think this should impact on the code.
Code:
'set the calendar visible for the date select
date_select.SetFocus
RunCommand acCmdShowDatePicker
Does anyone have any ideas what is going on here? Have I missed something simple?
Additionally, I need to confirm that the user can only enter a date as I use the entered date further on in some VBA. I could try and catch this later in the VBA code but I would prefer to nip the problem in the bud and force the user to only enter a date. Ideally, if I could actually disable keypresses that would be probably perfect, forcing the user to only select dates using the datepicker, but I'm not entirely sure if this is the most effective way, nor how to go about doing it. Anyone got any clues on this for me please?