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.
Import the following Objects from C:\Program Files\Microsoft Office\Office11\Samples\Northwind.mdb sample database:
- Table: Employees
- Form: Employees
Open the Employees Form in Design View.
Select the Company Info Tab.
Select the ActiveX Control option from the Insert Menu.
Select Microsoft Date and Timer Picker Control from the displayed list and click OK to create a control on the Form.
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.
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.
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.
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.
tanks for u
ReplyDelete[...] 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[...] 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[…] does appear to be one in Access 2010. http://msaccesstips.com/2010/02/micr...icker-control/ Reply With […]
ReplyDelete