if not isnull(this.activecontrol) this.lValidated=this.activecontrol.valid() if not this.lvalidated this.lastActiveControl=this.activecontrol else this.lastActiveControl=null endif else this.lvalidated=.t. this.lastActiveControl=null endifThen in the .activate
if not isnull(this.lastactivecontrol) this.lastactivecontrol.setfocus endifOf course, this would need a little more checking, making sure the lastactivecontrol is null initially. You may also have problems if form.deactivate happens during a valid() (could create a loop if you don't check for that), or some other problems (messagebox(), popping up any child form), but these can be worked around.