>Hi all,
>
>Reviewing another application that is giving me heartburn. There is a trick I learned a while back that I would like to share and why it's important.
>
>When data on a form is being edited, it's a good idea to SetFocus to the first control. This may seem like a nobrainer, but if you don't do it and the user hits "Add" or "Modify" then the focus never leaves that commandbutton.
>
>A really easy way to do it is to add a custom property to your form class such as "FirstEditControl" and default it to blank. In the instances of the form class, you can fill it in with "ThisForm.txtFirstName" or whatever and then put the following code in the Add or Modify method as the last thing to do:
>IF !EMPTY(ThisForm.FirstEditControl)
> cEditControl=ThisForm.FirstEditControl
> &cEditControl..SetFocus()
> &cEditControl..Refresh()
>ENDIF
My framework does almost exactly this, but I ran into a thing or two after implementing it that I had to code for- specifically, if the edited control lives on a page in a pageframe, you'll want to activate that page too:
IF !EMPTY(THIS.FirstEditField)
oFirstControl = EVAL(THIS.FirstEditField)
IF TYPE("oFirstControl.Name") = "C"
IF UPPER(oFirstControl.Parent.BaseClass) = "PAGE"
lnPageOrder = oFirstControl.Parent.PageOrder
oFirstControl.Parent.Parent.ActivePage = lnPageOrder
ENDIF
oFirstControl.SetFocus()
ENDIF
ENDIF
good tip.
Erik Moore
Clientelligence