PDA

View Full Version : Solved: Auto completion of Dates



Aussiebear
12-20-2006, 06:17 AM
In another thread Bob gave rise to the concept of a date entry which could be autocompleted.

Firstly I'm assuming that it would function based on what ever the current month selected is, and is it possible therefore if you had been using a running set of dates for a month, that it would move into the next month if you moved past the end of month date?

Secondly, and most importantly how is this done using vba?

Ted

Aussiebear
12-20-2006, 06:23 AM
Just had a second thought about the above post....

Is it possible for the last date used to be shown in a pop up window when the particular cell has focus, and inside the window is two arrows to enable one to move forward ( or backward) in dates by say by using a click and hold method?

JimmyTheHand
12-20-2006, 04:15 PM
Ted, more info is needed here. Give us details. I can't see what you have envisioned, and I think I'm not alone with this.

Bob Phillips
12-20-2006, 04:56 PM
Ted,

What I meant was that if the user input just days, you would automatically add the current month and year, if they input days and month, you automatically add the year. In this thinking there woud be no concept of moving into the next month.

You could also add it in the textbox, and still allow the user to over-type any part of it, but this is a lot more complex to code, to manage the parts typed in and the other parts and allow further input, backspace, delete keys, etc., etc.

The simplest method is to add the calendar contriol to the form, and let the user pick the date.

Another simple way is to have three (well four actually) textboxes, one for the days, one for the month, one for the year, with spinner controls aligned to each that will scroll the days/months/years aup and down by one at a time, taking care to be bound by the limits (12 months etc.), and a fourth textbox reflecting the currently selected date.

CodeMakr
12-20-2006, 05:16 PM
How would you limit the bounds of the "days" text box? I missed the other post, so I can't figure out how you would keep someone from choosing Feb 31 for example? Would the day bound be tied to the month box in order to cap number of days?

Bob Phillips
12-20-2006, 06:02 PM
You would test one of the textbox exevents and check the value for validity. You have the same problem if you spinner controls, you have to set the upper bound of days depending on the month, doubly difficult with Feb. The easiest way is to just take the days 0th day of the next month as your limit.

IMO, if you are going to use a textbox input, the simplest way is to have a button or textbox exit event, auto-complete their date if necessary, and then validate it, and return to the textbox if invalid.

Aussiebear
12-21-2006, 12:44 AM
Since I'm in the mood for passing thoughts,.... I might just give this one a miss for now. Thanks to those who gave some advice on this matter.