tabsequence of controls on a form

  • Thread starter Thread starter Dale Fye
  • Start date Start date
D

Dale Fye

Using Access XP on a Windows XP Pro system.

I have a form that contains a subform. When I make any changes to the data
on the subform, I want to disable all of the controls on the main form until
the user has either saved or cancelled the changes they have made on the
subform (I've got this part working by running some code in the LostFocus
event of each of the controls on the subform). Maybe I should be doing this
in the controls AfterUpdate event instead of the LostFocus

Unfortunately, in order to disable all of the controls on the main form, I
have to set the focus in that form to a dummy control that has zero width.
At the end of my disabling code, I want to return the focus to the next
control that should get the focus in my subform, but have not been able to
figure out how to accomplish this. Any ideas?
 
What are you seeking to achieve here, Dale?

Access won't let the user out of the subform until the record is saved (or
undone.) If you need to run any validation on the record, use
Form_BeforeUpdate in the subform. If you cancel that event, the user can't
get out of the subform. There is therefore no need to disable the controls
on the main form.
 
Allen,

Thanks for your response. If you have another idea, I'd be glad to hear it.

The subform has about a dozen text and combo controls, and a tab control
with several tabs on it. It also has Save and Cancel command buttons. My
client wants me to disable the command button and treeview controls on the
main form whenever a change has been made in the subform. Their perception
is that the command buttons (navigation, add, delete, close) on the main
form are confusing, and with them disabled, the subform would have all of
the users attention. So I'm trying to comply with their wishes.

I've moved the disable code to the GotFocus events of the textboxes on the
subform. It checkes to see whether the form is dirty, and if so, whether I
have already disabled the keys on the main form. If not, it stores the
Screen.ActiveControl in a variable, sets the focus to the dummy field on the
main form, disable the necessary controls, then set the control back to the
control variable. That seems to work.

Dale
 
Okay, I guess you might use the Enter event of the subform *control* to
disable the other controls on the main form (leaving at least one other
(unbound?) one available), and re-enable them in its Exit event.

I'm not sure I'd like that interface, and there is a bug in Access where the
subform's Enter event doesn't fire somtimes (involves requering in
Form_AfterUpdate or Form_AfterInsert.)

A cancel command button on the form can also be frustrating: you can't get
out of the box you are in to get to the cancel button if the active control
has a partical entry (e.g. a partial date, or a number or stirng that
doesn't meet validation, or where you backspaced the value out of a required
field.)

It might be better to create a custom toolbar. Add the nav buttons there, as
well as your Save Record and Undo buttons. Apply it to both the main form
and subform. The toolbar buttons work correctly on whatever form you're in.
 
Back
Top