Learn Microsoft Access Advanced Programming Techniques, Tips and Tricks.

Microsoft Date Time Picker Control

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 easy to use.

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 ActiveX Control. . . from 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:

    We must know 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 HireDate 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 value to NULL when CheckBox Property=FALSE.

    The Error message indicates that 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.

  7. So, first thing first, ensure that the Date Time Picker Control you have added to the Form is in 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 like disabled indicating that it is empty but the field shows the date value of last record accessed. If you click on the drop down control of the Calendar to open it then the date value, shown from last accessed record will be entered into the HireDate field immediately, whether you want it or not. You can remove the CheckMark to empty the field or select 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 on 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.
  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 appear in place of the drop-down control and these can be used to set each segment (hh:mm:ss AM/PM) of the Time Value individually as explained above for date.
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

Translate



PageRank
Your email address:

Delivered by FeedBurner

Search

Infolinks Text Ads

blog.feedspot.com Microsoft Access Blogs

Popular Posts

Search This Blog

Blog Archive

Powered by Blogger.

Labels

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

Featured Post

Base Class and Derived Object Variants

Last week we have tried an example as how to pass a Base Class Object, through the Set Property Procedure,  to become part of the Object in...

Labels

Blog Archive

Recent Posts