To add a date/time picker control to a custom form
The Outlook Appointment, Task and Journal forms include a drop-down calendar control on their main pages that allows the user to quickly pick a date. This built-in drop-down control is not available to programmers of legacy custom forms. (This is apparently one reason why certain pages on Outlook forms are not customizable.)
Among the new controls introduced to support form regions in Outlook 2007 are both date and time pickers. However, these are not designed for use on legacy forms. Using them there may cause form corruption and loss of code behind the form.
Microsoft and third-party sources provide other ActiveX controls that you may find useful in Outlook legacy custom forms. Any such control must be available on each client machine. You may find that the inconvenience of distributing the control outweighs its usefulness, especially given that text boxes bound to Outlook date/time fields support natural language entries like "tomorrow" and "next Monday" that most date pickers can't handle.
As you evaluate which control is useful for your application, you may want to ask these questions about the controls you're considering.
- Can the control be bound to an Outlook Date/Time field?
- Does the control support the Click event?
- Does the control provide a way for the user to easily to set the date to None (which in Outlook is actually #1/1/4501#)?
- Does the control support Outlook-style AutoDate entry functionality, such as "1w" for "one week from today"?
Martin Luckfiel in Germany provided these notes on using the ActiveCalendar control. They apply (more or less) to any date picker control:
- Add the control to the forms design Toolbox.
- Drag the control from the Toolbox to the custom form page.
- Use the Value tab of the control's Properties dialog to bind the control to the appropriate date/time field.
- Set the date/time format. (ActiveCalendar seems to require a format like "10 August, 1999" for the binding to work properly.)
- Add code to the form's Item_Open event handler to maintain the proper size of the control. (These controls tend to resize themselves. Finding the right values for the code may take some trial and error.) Here's an example:
Publishing an Outlook form does not also install and register the ActiveX controls found on the form. You must develop your own separate mechanism for distributing, installing and registering the controls. Otherwise, users will get an error message. A package that runs with a Setup.exe or a web page with a reference to the control in a .cab file are both viable solutions. See any basic Visual Basic reference for more on distributing ActiveX controls.