Hi Jon
ActiveControl may not be an object if no object is active IOW if no object has focus. (the form may not be the one in focus?)
check like
IF TYPE('THISFORM.ActiveControl')='O' AND !ISNULL(THISFORM.ActiveControl) THEN
....
ENDIF
Note that form.ActiveControl may point to a container, the container itself uses ActiveControl too.
To the second part.
Check valid event. The return value will set the focus.
You may also use object.setfocus, but note that this will not work from when/valid events. See setfocus
I personally think this will be tricky, because you will need to know in what way the user leaves the object (mouse/tab/shift tab)
Agnes
>Hi All,
>
>Two questions in one here I'm affraid!!
>
>Firstly, I'm having a problem with using the activecontrol property. Basically I have a form which has a panel control on it and then all the actual text boxes sit on the panel control. If I call _screen.activeform it gives me all the correct info about my form. However, what I really want to do is be able to find out which control has focus.
>
>I have tried _screen.activeform.activecontrol and also _screen.activeform.cntpanel.activecontrol to account for the panel I have added but for some reason it always returns 'expression cannot be evaluated'.
>
>What am I doing wrong here?
>
>Secondly, on the form I wish to be able to skip over certain controls if some specific condition is met and move on to the next control. So for example 3 textboxes and if you enter 'a' in the first one you cannot get into textbox2 but go directly to textbox3. I have looked at the tabstop but that doesnt stop you clicking into the control. Any ideas?
>
>It's been a long time since I developed in VFP and I think its showing!!!!
>
>Thanks
>
>Jon
Words are given to man to enable him to conceal his true feelings.
Charles Maurice de Talleyrand-Périgord
Weeks of programming can save you hours of planning.
OffThere is no place like [::1]