(Q) I have a form with a date field or a
block of code that needs to
input a date and I want to the user to have a calendar view to
that date from. I don't want to use any ActiveX components.
(A) Use the Access Date Picker.
Download the attached database
and import the form "DatePicker" and the
module "mdlDatePicker" into your project.
Make a CommandButton next to the form's TextBox containing the
add some code to its Click event like this:
Private Sub DateButton_Click()
(You might want to use Access' built-in "Calendar" icon as the
InputDateField DateTextBox, "Some prompt"
CommandButton's picture, and leave the caption blank.)
If you have a block of code that needs to stop and ask for a
date as it
runs, do something like this:
Private Sub SomeAction()
Dim d As Variant
' Initialize whatever needs initializing
d = InputDate("Some prompt")
' d is now a date (IsDate(d) = True) or Null, if the user
' Do something with useful with d.
InputDateField() will not affect the specified TextBox if the
clicks the Cancel button on the DatePicker form. Likewise you
aware that InputDate() will return a Null value instead of a
date if the
user clicks Cancel and your code must handle it appropriately.
Other features include specifying the initial date that the
form presents to the user. See the readme file for more details.