"DATE ENTRY WITH CALENDAR" component by Tom Dillon
This component consists a set of routines and a popup calendar to make date entry fields more flexible for the end user.
When installing the component you will be warned that the table [Demo] does not exist. Click the Link button and select the table in which you keep dialogs and such.
The date handling code consists of only two methods, DE_HandleDate and DE_StringToDate. Call DE_HandleDate(Self) from within a date field to make it do its thing. You also need to enable the On Before Keystroke and On Data Change events for the field.
DE_HandleDate consists largely of a Case statement that handles special function keys that place particular dates into the date field. More dynamic functions could easily be added, such as first day of the currently entered month, add a month, etc. It retrieves the date information from the field using Get Edited Text.
DE_StringToDate takes the string of the fully or partially entered date and does its best to interpret it as a date.
The calendar part of the component consists of a few project methods, a form and a handful of picture library items.
DE_DisplayCalendar displays the calendar dialog next to the date field.
DE_SetDate sets the date as directed by two parameters, the Function and Operator.
DE_MonthName returns that name of the numeric month.
DE_MonthNum returns home after staying out too late. (And the month number from the name. (English only))
DE_SetYearMenu creates the Year menu and set the menu location to the currently assigned year.
DE_CloseWindow is just a call to Cancel and is used only as a parameter in Open Window from DE_DisplayCalendar.
Using Date Entry
Date entry assumes that dashes, slashes, spaces, or any nonnumeric character not associated with a function are day, month and year separators. It also defaults to the current month and year if not specified. For instance entering a 5 would result in the fifth day of the current month and year. MMDDYY and MMDD entry are supported.
Month/Day/Year or Day/Month/Year order are based on the system's date settings.
Shortcut keys
M - First day of the current (M)onth
H - Last day of the current mont(H)
Y - First day of the current (Y)ear
R - Last day of the current yea(R)
T - (T)oday
C - (C)alendar
K - Clear date
+ - Add one day
- - Subtract one day
Using The Calendar
The calendar opens to the date displayed in the field or the current date if the field is empty.
Clicking on a date assigns that date to the date field.
The arrow keys navigate the calendar.
[cmd/ctrl] plus the left or right arrow keys change years.
[shift] plus the left or right arrow keys change months.
The plus and minus keys add or subtract one day.
The L key does nothing!