Home » Access Tips And Tricks » Date/time picker for Microsoft Access

Date/time picker

Over the years, I have seen many posts on the Access groups and forums asking for a date/time picker other than the one built into Access 2007 and subsequent version.  A client recently mentioned that he wanted to be able to pick a date and a time for a date field in his application, so I dusted off an old (Access 2000) form which I had created for selecting dates, made a few modifications and came up with the following.  With this form, and a single code module I am now able to select either a data, date and time or just a time.  The example below shows both the date and time portions of the dialog box, but you can also display either one of them, if you wish.

Instead of setting the Show Date Picker property of a textbox, I have added a shortcut menu (DateTimePicker) which contains a single control.  I assign this shortcut menu to the Shortcut Menu Bar property of a text box so that when I right click on a date/time field, it pops up a shortcut menu which when clicked, popups up the appropriate type of selection dialog box.  Make sure that when you import these forms and code module into your application, you also copy the shortcut menu mentioned above (GetExternalData => Options => Menus and Toolbars).

The only other addition you must make to the textbox on your form is to set the OnGotFocus event of the control to configure your popup to either date, date/time, or time. This is done with a single line of code:

=setDatePicker()
=setDateTimePicker(15)   ‘the 15 indicates the time interval (minutes) to display between entries in the time picker
=setTimePicker(30)

As you can see, this configuration step allows you to select the timer interval between items in the time picker.

Without too much additional work, this form and code module could be modified to accept parameters which would only allow the user to select dates, or times within user specified parameters (On or after some date, After some date, between dates, On or before some date, Before some date).

Feel free to download this form and code module and modify it to meet your needs.

 

 

 

3 thoughts on “Date/time picker for Microsoft Access

  1. James Cook says:

    Very Nice thank you.

    1. Dale says:

      James,

      Glad you like it, but I made a couple of additional changes today, to speed up loading of the list of times. The latest version is now posted here on the site.

      Although the file names are the same, you will find a new table (tbl_Minutes) and query (qry_TimeIntervals) in this new version of the application.

  2. Jerry Lutz says:

    Dale has been great assisting with getting this awesome date time picker setup in my application. Saved me many hours of searching on google for something that should just be automatic within access. Great Job Dale!

Leave a Reply

Your email address will not be published. Required fields are marked *

Name *
Email *
Website