Date Entry with Calendar

With more dancing leprechaun!

This little chunk of code allows you to use 4D's date fields to enter partial dates and have them interpreted properly.

You know how frustrating it is when your users call you up to tell you that when they enter dates "they don't stick". "I entered 10/28 in the date field and when I tabbed out it turned to 00/00/00." You tell them that they have to enter the year too and they tell you that it doesn't work that way in QuickBooks.

Before the Get Edited Text function and the On Before Keystroke event the only way to do what the Date Entry part of this component did was to use a string variable for the entry, interpret the string and assign the resulting date to your date field. Marla Steinburn wrote some very slick code to handle the interpretation which I used as the basis for the String To Date code.

Now, with Get Edited Text and On Before Keystroke it's possible to handle date entry right in a 4D date field. Plus, shortcut keys can be added. The date entry code is set to use the same shortcut keys as QuickBooks: + & - to add or subtract one day, etc. (See the docs page.) You can also add whatever shortcut keys you want in the DE_HandleDate method.

The calendar pops up when you hit the C key while in the date field. A help window opens when you type a question mark in the date field too. The help window is not available from the calendar though. It seems that after closing it, input is no longer accepted from the keyboard in the calendar.

Also, I misplaced the month and year nav icons, so I'm using the old standard angle brackets. I've left the pictures in place, but they point to nothing right now.

Just enable On Before Keystroke and On Data Change for the date field and add DE_HandleDate(Self) to the object method and you're good to go.


Take a look at the Docs for an explanation of how to use it.
Download the 4D v12 Example DB
Download the 4D v12 Component

It's all just 4D and the source is available in the demo database.