2013-01-10

I have been selecting dates in my projects using the =fBuildBasedOnContext("Get Date") function, courtesy of "Peter's Software", for some time now. This is one of the coolest tools in his suite of Proximity Tools. But I now need to validate the selection and not allow users to choose a date outside of a given range. This isn't rocket science, I know. But it has come to my attention that when using this function, the calling form (the one the date picker button is on) never gets the focus back. Or so it seems...

What I want to happen is this:
- if the selected date is valid, set the focus to the next textbox on the form so the user doesn't have to click into it
- if the selected date is NOT valid, the focus should move to the date field textbox

Simple right?

What seems to be happening is after the selection is made in the calendar control, the focus 'kind of' reverts to the cmd button that launches the calendar.
I placed code in the click event to deliberately set the focus to some other controls on the form. And each time, the code runs without error. But the insertion point (cursor) is not visible in the controls. And when I try to tab through the controls, nothing happens!

I have checked the focus using things like ?Application.CurrentObjectName, Application.Screen.Activeform.name, Application.Screen.ActiveControl.name from the Immediate pane. All report that the proper form/control have the focus. But it doesn't LOOK like it does, and I can't tab through the rest of the controls.

It almost seems like there might be something going on with Window 'handles'? This is deeper than I ever go, but the one thing that sticks in my head is that Peter grabs a hWnd value from a form in Access in which he builds his calendar/date picker. Could it be that the Application can only have one handle referenced at any one time? I can't really tell if he releases the handle when the calendar form closes.

I am out of ideas and have burned WAY too many hours on this today. Any thoughts?

Oh, yeah - This is an Access 2003 project. The irony is they will likely want to upgrade the office to Office 2010 in about 6 months. But I need this done this week! So i can't wait for the data picker feature in 2010...

Looking forward to hearing what I missed!

Thanks,
RichP

Show more