D
dmcheng1
I have a form / subform focus problem that's driving me crazy.
Here's my setup: I have an Access 2002 ADP connecting to a SQL 2000
db. On the data entry form (single record), I do not use the Access
navigation buttons. Instead, all the data fields are Disabled by
default, and I built Add and Edit buttons along with Previous and Next
arrow buttons. The user can click through and view the records, but
must click the Edit button to edit the data fields. If they decide to
cancel the edit, they click the Cancel button that I provide.
I have used the Tag property to tag all the data fields as "Data." I
have a routine that loops through form's controls and enables/disables
the tagged controls. So, when you click the Edit button, the routine
enables the data fields. Clicking on the Cancel button disables the
fields.
So far so good. The problem occurs with a subform that I have on the
main form. If the user clicks Edit, then clicks into the subform, and
then decides to click the Cancel button on the main form, I get an
error "Field cannot be disabled while it has the focus" and the field
that is causing the error is on the subform.
I have tried everything I can think of to move the focus back to the
main form when the Cancel button is clicked:
* In the subform's OnExit, setting the focus to the main form and then
to an enabled control on the main form.
* On the main form itself, I select the subform's control, and in the
OnExit, setting the focus to the main form and then to an enabled
control on the main form.
* In the Cancel's button's OnClick, setting the focus to an enabled
control on the main form.
None of these work. Is there something else I can try?
Thanks
David
Here's my setup: I have an Access 2002 ADP connecting to a SQL 2000
db. On the data entry form (single record), I do not use the Access
navigation buttons. Instead, all the data fields are Disabled by
default, and I built Add and Edit buttons along with Previous and Next
arrow buttons. The user can click through and view the records, but
must click the Edit button to edit the data fields. If they decide to
cancel the edit, they click the Cancel button that I provide.
I have used the Tag property to tag all the data fields as "Data." I
have a routine that loops through form's controls and enables/disables
the tagged controls. So, when you click the Edit button, the routine
enables the data fields. Clicking on the Cancel button disables the
fields.
So far so good. The problem occurs with a subform that I have on the
main form. If the user clicks Edit, then clicks into the subform, and
then decides to click the Cancel button on the main form, I get an
error "Field cannot be disabled while it has the focus" and the field
that is causing the error is on the subform.
I have tried everything I can think of to move the focus back to the
main form when the Cancel button is clicked:
* In the subform's OnExit, setting the focus to the main form and then
to an enabled control on the main form.
* On the main form itself, I select the subform's control, and in the
OnExit, setting the focus to the main form and then to an enabled
control on the main form.
* In the Cancel's button's OnClick, setting the focus to an enabled
control on the main form.
None of these work. Is there something else I can try?
Thanks
David