Application.RunCommand (acCmdShowDatePicker)
Private Sub YourDateField_GotFocus()
DoCmd.RunCommand acCmdShowDatePicker
End Sub
Private Sub YourDateField_GotFocus()
If Nz(Me.YourDateField, "") = "" Then
DoCmd.RunCommand acCmdShowDatePicker
End If
End Sub
Used in the GotFocus event of a DateTime Textbox, as defined above, the code ALex gave
Application.RunCommand (acCmdShowDatePicker)
or
DoCmd.RunCommand acCmdShowDatePicker
will cause the DatePicker to popup up when the Texbox is entered, doing away with the necessity of clicking on the icon.
Code:Private Sub YourDateField_GotFocus() DoCmd.RunCommand acCmdShowDatePicker End Sub
If you only want the Datepicker to pop up if the Textbox doesn't already have a Date in it:
Linq ;0)>Code:Private Sub YourDateField_GotFocus() If Nz(Me.YourDateField, "") = "" Then DoCmd.RunCommand acCmdShowDatePicker End If End Sub
you probably aren't referring to the subform correctly, but that's just a guess because you didn't provide any code for your attempt.
referencing CONTROLS on subform:
[Forms]![Main form name]![subform control name].[Form]![control name on subform]
e.g.
[Forms]![frmNP]![subNPfrm].[Form]![txtNPno]
frmNP is main form name
subNPfrm is name of subform control on frmNP
txtNPno is the textbox control name
Hi. Assuming fld_Date_trec is bound to a date/time field, do you have anything in its Format property? Just curious...im using the code:
Private Sub fld_Date_trec_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
DoCmd.RunCommand acCmdShowDatePicker
End Sub
this code is on the subform.
Main form is "frmPersonnel"
Subform Control Name is "SubFrmHistory"
Subform name is "frm_Personnel_sub_history"
how do i modify the code to get it working?
Hi. Assuming fld_Date_trec is bound to a date/time field, do you have anything in its Format property? Just curious...
Okay, that's useful information. What happens if you use the Focus event instead? Same problem?yea fld_date_trec is the date field and has no format applied.
The code works fine when the form is opened on its own, but fails when opened as a subform.
Okay, that's useful information. What happens if you use the Focus event instead? Same problem?
Okay. It may be something obvious we can't see from here. Let's forget about the code for the moment. What happens if you click into the field in the subform? Do you see the date picker button show up?Yea same error.
Okay. It may be something obvious we can't see from here. Let's forget about the code for the moment. What happens if you click into the field in the subform? Do you see the date picker button show up?
Okay, that verifies the date picker could be available. Unfortunately, it would be hard at this point to say exactly why it's not available without being able to review your db. Are you able to post a sample copy?Yes, when the field has focus the datepicker icon is floating to the right as normal and work as expected.
Heres a basic example of the issue.Okay, that verifies the date picker could be available. Unfortunately, it would be hard at this point to say exactly why it's not available without being able to review your db. Are you able to post a sample copy?
Okay, thanks. I'll take a look once I get in front of a computer, unless someone beats me to it.Heres a basic example of the issue.
open frmpersonnel_sub_history, code works fine.
open frmpersonnel where "frmpersonnel_sub_history" is embedded as a subform and it doesnt.