Learn Microsoft Access Advanced Programming Techniques, Tips and Tricks.

Microsoft Date Time Picker Control

Introduction

We have learned how to use Calendar Control for easy entry of Date Values into Fields on Form through the earlier Article: Animated Floating Calendar. We have used a single Calendar Control for several Date Fields by moving the Calendar Control automatically near the selected Date Field with unfolding animation.

We have used this method to save space on the Form otherwise we need to place several Calendar Controls linked to each date field on the Form.

Now, we have a better ActiveX Control Microsoft Date Time Picker - a Calendar Control that almost looks like a Combo Box on Form, and is very easy to use.

Learn its Simple Usage.

Let us get into 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 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 on the sample design of the Form given below:

    Few Simple Rules of Date/Time Picker Control.

    We must know a few simple rules that go with this Control to use it with Date Fields.

    • We can set the Control Source Property of Date Time Picker to HireDate and remove the existing HireDate Field.

    • The Hire Date field cannot be blank. When you make a record current with HireDate Field blank or attempt to add a new record the Date Time Picker will show an Error Message: Can't set the value to NULL when CheckBox Property=FALSE.

    The Error message indicates that the HireDate field cannot be left blank or you cannot remove Date Value from a field and make it blank unless you set the CheckBox Property of the Date and Time Picker Control to Yes.

    Important Settings.

  7. So, first thing first, ensure that the Date Time Picker Control you have added to the Form is in the selected state or click to select it, display the Property Sheet (View - -> Properties or Alt+Enter) of the Calendar Control and change the Control Source Property Value to HireDate and change the CheckBox Property Value to Yes.

    .
    • When you move to a particular record the Calendar will automatically move to the date earlier recorded in the HireDate Field. If you want to change the existing HireDate then move the Calendar to the desired Year and Month and click on the required date.

    • When you move to a record with HireDate Field value NULL the Check-Mark disappears and the HireDate field looks disabled, indicating that it is empty, but the field shows the date value of the last record accessed. If you click on the drop-down control of the Calendar to open it, then the date value, shown from the last accessed record will be entered into the HireDate field immediately, whether you want it or not. You can remove the Check Mark to empty the field or select the correct date from the Calendar to overwrite the wrong value.

    • If you prefer to set Date by incrementing or decrementing individual segment (day/month/year) of the Date value, like you do with a Digital Clock, then you may change the UpDown Property value to Yes. This will change the Drop-down control of the Calendar to a Spin Button Control and the normal Calendar View will not be available.

    • You may click on the Day Segment of the Date value and use the Spin Button Control of the Date Time Picker to increase or decrease the value to the desired level. Use the same method for Month and Year Values.

  8. You may experiment with the Date Time Picker Control, keeping those points I have mentioned above, to understand the behavior of the Calendar control better.


    Settings for Time Value.

  9. If you want to enter Time rather than Date into a field from the Date Time Picker then change the Format Property Value to 2. This will automatically change the UpDown Control to Yes and the Spin Button control appears in place of the drop-down control, these can be used to set each segment of hh:mm:ss AM/PM of the Time Value individually as explained above.

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