>>>Is there a better way in general of setting the control which is to receive initial focus at run-time? There are many examples of why you would want to do this, eg using the same form for adding a new record and editing an existing record. In the case of adding you would want the first user editable control (say a textbox) to be selected. In the case of editing you would want the OK button selected.
>>
>>How about setting the tab order for all other controls to something higher (maybe you can do that in design mode), and have the optiongroup have taborder=1? That should give it the focus without any extra action.
>
>The option group has the focus BUT the first option button has the actual focus not the option button that I wish to have focus. If the user presses say "spacebar" the option with the dotted line around it (the first) not the option which is selected, gets "pressed". Even setting "value" doesn't help.
I've tried this in form's .gotfocus():
this.optiongroup1.Buttons[this.optiongroup1.value].setfocus
and it worked, but in general case this is still bad, because the form may have lost focus when you had any other control having focus, so restoring focus to your form would always return focus to the optiongroup. Ideally, if optiongroup had a .gotfocus event, that would be the best place to put the above command, but it doesn't.
So, the trick is to put the optiongroup into a container, which does have a .gotfocus, and the command to set the focus to the correct optionbutton goes there. Tried, works.