Learn Microsoft Access Advanced Programming Techniques, Tips and Tricks.

Microsoft Date Time Picker Control

Introduction

In an earlier article, Animated Floating Calendar, we learned how to use the Calendar Control to simplify date entry form fields. In that method, a single calendar control was used for multiple date fields by automatically moving it near the selected field with a smooth unfolding animation.

This approach helps to save space on the Form; otherwise, we would need to place separate calendar controls for each date field.

Now, we have an even better alternative — the Microsoft Date and Time Picker (DTPicker), an ActiveX control that closely resembles a Combo Box and is extremely easy to use.

Learn its Simple Usage.

Let us try a simple example to learn how to use this Calendar for a Date Field on a Form.

  1. Import the following Objects from C:\Program Files\Microsoft Office\Office11\Samples\Northwind.mdb sample database:

    • Table: Employees
    • Form: Employees
  2. Open the Employees Form in Design View.

  3. Select the Company Info Tab.

  4. Select the ActiveX Control option from the Insert Menu.

  5. Select the Microsoft Date and Timer Picker Control from the displayed list and click OK to create a control on the Form.

  6. Move the control near the HireDate Field and resize it as shown in the sample design of the Form given below:

    Few Simple Rules of Date/Time Picker Control.

    • Before using the Date and Time Picker control with date fields, it’s important to understand a few simple rules.

      You can set the Control Source property of the Date and Time Picker to a field, such as HireDate, and remove the existing HireDate text box from the form.

      However, note that the HireDate field cannot be blank. If you navigate to a record where the HireDate field is empty, or if you try to add a new record without assigning a date, the control will display the following error message:

      “Can’t set the value to NULL when CheckBox property = FALSE.”

    This error message indicates that the HireDate field cannot be left blank, and you also cannot clear the date value from the field once it has been set—unless the CheckBox property of the Date and Time Picker control is set to Yes.

    Important Settings.

  7. First things first—make sure the Date and Time Picker control you added to the form is selected. Then, open the Property Sheet (by choosing View → Properties or pressing Alt + Enter) and make the following changes:

    • Set the Control Source property to HireDate.

    • Set the CheckBox property to Yes.

    When you navigate to a record, the Date and Time Picker will automatically display the date stored in the HireDate field. To change the existing hire date, simply move the calendar to the desired year and month, then click the required date.

    If you move to a record where the HireDate field is NULL, the check mark will disappear, and the field will appear disabled, indicating that it’s empty. However, the control may still display the date from the previously accessed record. If you open the calendar drop-down, that previous date will automatically populate the HireDate field. You can either remove the check mark to clear the field or select a new date from the calendar to overwrite the value.

    If you prefer to adjust the date manually—by incrementing or decrementing the day, month, or year like you would on a digital clock—set the UpDown property to Yes. This changes the calendar’s drop-down into a spin button control, replacing the standard calendar view.

    Once enabled, click any date segment (day, month, or year), and use the spin buttons to increase /decrease the value to your desired setting.

  8. You can experiment with the Date and Time Picker control, keeping the points mentioned above, to better understand how the calendar behaves under different settings.


    Settings for Time Value.

  9. If you want to enter time values instead of dates using the Date and Time Picker control, change its Format property value to 2. This automatically sets the UpDown property to Yes, replacing the drop-down calendar with a spin button control. You can then use the spin buttons to adjust each segment of the time value — hours (hh), minutes (mm), seconds (ss), and AM/PM — individually, just as explained earlier.


Share:

4 comments:

  1. [...] Office toolbars, ribbons, task panes on RO Chrome - Add-in Express Blogs LEARN MS-ACCESS TIPS AND TRICKS - Microsoft Date Time Picker Control LEARN MS-ACCESS TIPS AND TRICKS - Keyboard Shortcuts LEARN MS-ACCESS TIPS AND TRICKS - Database [...]

    ReplyDelete
  2. [...] You should know few things about Date/time Picker control, take a look at the following link: http://www.msaccesstips.com/2010/02/...icker-control/ [...]

    ReplyDelete
  3. […] does appear to be one in Access 2010. http://msaccesstips.com/2010/02/micr...icker-control/ Reply With […]

    ReplyDelete

Comments subject to moderation before publishing.

PRESENTATION: ACCESS USER GROUPS (EUROPE)

Translate

PageRank

Post Feed


Search

Popular Posts

Blog Archive

Powered by Blogger.

Labels

Forms Functions How Tos MS-Access Security Reports msaccess forms Animations msaccess animation Utilities msaccess controls Access and Internet MS-Access Scurity MS-Access and Internet Class Module External Links Queries Array msaccess reports Accesstips WithEvents msaccess tips Downloads Objects Menus and Toolbars Collection Object MsaccessLinks Process Controls Art Work Property msaccess How Tos Combo Boxes Dictionary Object ListView Control Query VBA msaccessQuery Calculation Event Graph Charts ImageList Control List Boxes TreeView Control Command Buttons Controls Data Emails and Alerts Form Custom Functions Custom Wizards DOS Commands Data Type Key Object Reference ms-access functions msaccess functions msaccess graphs msaccess reporttricks Command Button Report msaccess menus msaccessprocess security advanced Access Security Add Auto-Number Field Type Form Instances ImageList Item Macros Menus Nodes RaiseEvent Recordset Top Values Variables Wrapper Classes msaccess email progressmeter Access2007 Copy Excel Export Expression Fields Join Methods Microsoft Numbering System Records Security Split SubForm Table Tables Time Difference Utility WScript Workgroup database function msaccess wizards tutorial Access Emails and Alerts Access Fields Access How Tos Access Mail Merge Access2003 Accounting Year Action Animation Attachment Binary Numbers Bookmarks Budgeting ChDir Color Palette Common Controls Conditional Formatting Data Filtering Database Records Defining Pages Desktop Shortcuts Diagram Disk Dynamic Lookup Error Handler External Filter Formatting Groups Hexadecimal Numbers Import Labels List Logo Macro Mail Merge Main Form Memo Message Box Monitoring Octal Numbers Operating System Paste Primary-Key Product Rank Reading Remove Rich Text Sequence SetFocus Summary Tab-Page Union Query User Users Water-Mark Word automatically commands hyperlinks iSeries Date iif ms-access msaccess msaccess alerts pdf files reference restore switch text toolbar updating upload vba code