General information
Category:
Coding, syntax & commands
>>>Is it possible to detect which control has a tab order of "1" and to set focus to that control?
>>
>>lnMin = 9999
>>
>>FOR lnI = 1 TO _Screen.ActiveForm.ControlCount
>> IF _Screen.ActiveControl.TabIndex < lnMin
>> lnMin = _Screen.ActiveControl.TabIndex
>> loControl = _Screen.ActiveControl
>> ENDIF
>>ENDFOR
>>
>>loControl.SetFocus()
>
>How do you set the focus to a Label object? What if the object is disabled?
>
>Besides, you should use ActiveForm.Controls[lnI] instead of ActiveControl.
>
>Vlad
Thanks to all of you for responding so quickly. I posted this message at work and by the time I got home... wow!
Anyway, here's what I finally came up with:
* set focus to first field
IF THISFORM.DEMode <> "VIEW" && ADD or EDIT
nCtlNo = 1
DO WHILE nCtlNo < 99
IF THIS.CONTROLS(nCtlNo).TABINDEX = 1
THIS.CONTROLS(nCtlNo).SETFOCUS
nCtlNo = 99 && jump out of loop
ELSE
nCtlNo = nCtlNo + 1
ENDIF
ENDDO
ENDIF
Note that:
- All edit controls (textbox, combo box, checkbox, etc) are disabled in
VIEW mode and VIEW is the startup mode.
- I set the Tab Order to 1 for the 'first' field.
- this approach does not continue to test further once it finds the
'first' field.
- my standard form has a two-page pageframe with page one for 'Data Entry'
and page two for 'List'
- this code is in the Refresh method of Page1
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only