>i have a txtfrdate and txttodate in my form. i want to set txttodate.value when txtfrdate loses focus. so in txtfrdate.lostfocus() i do,
>
>
thisform.txttodate.value=thisform.txtfrdate.value
>
>this works fine.
>
>i enter 05/21/2004 in txtfrdate, but at txttodate, when i type only upto 05/24 .......... and press my save button......... txttodate changes to the value of txtfrdate.
>
>how can i avoid this? both textboxes are set initially to date().
It seems like your save button is in a toolbar. Since toolbars never really get focus, your second textbox hasn't lost it yet, so its value is not updated from what your user typed. And when you come back to it, it gets refreshed to this previous value. You need to force the validation and losing of focus for the active control, so to simulate the natural course of events.
The old trick to do it is in the savebutton.click
oForm=_screen.activeform
oCmd=oForm.activecontrol
oCmd.SetFocus()
...your regular click code here...
Of course, you'll need to check whether oForm is null, and whether oCmd is null, in case there's no active form (as when debugging or menu activated) or no active control (similar cases), but this was reported to work. Didn't try it myself, don't use toolbars for form-related stuff; my toolbars are either on-form or app level.
The trick here is in the oCmd.SetFocus() - we're setting focus to the same control, but to gain focus, it first has to lose it, which is what we wanted. I think I've read this from David Frankenbach here, few years ago.