cannot exit from sub from to main form

  • Thread starter Thread starter CarWashMike
  • Start date Start date
C

CarWashMike

For some reason I cannot exit from a subfrom to the main from, I have auto
tab set to yes on the data entry controls, and a who created field set to the
after update property of the subform but when I try to tab out of the last
data entry control I get stuck in the sub from - what am I doing wrong any
ideas thanks
 
Use the BeforeUpdate event procedure of the subform to record the date of
update, not its AfterUpdate event.

If you use Form_AfterUpdate to change the value, it needs saving again. Then
as soon as it is saved, you dirty it again so that it needs saving again.
You can't get out of the subform because it needs saving, and as soon as you
do that, it needs saving again.

You can actually get out by pressing Esc (to undo the recording of the
update date), but that does not do what you need.

Form_BeforeUpdate fires at the last possible moment before the record is
saved, so is ideal for your purpose.
 
Thank you very mush thats great, is it possible to to tab out of the sub
form back into the main form. When I tab on the last data entry control it
created a new record in the sub form it would be great if it would take me
back to the main form.
 
As you found, the subform does not automatically tab back to the main form.
Typically there is a one-to-many relation between the main form's table and
the subform's table. Therefore you may have more records to add in the
subform. Are you sure it makes sense to automatically tab back to the main
form?

Would it be better to provide a hotkey for jumping back to a particular
control on the main form? That's just a matter of adding an Ampersand to the
attached label for some control. For example, if you have a Surname text box
you want to jump back to, you change the Caption of the attached label to:
&Surname
and then Alt+S jumps there.

If you are quite sure that you should automatically jump out of the last
control in the subform back to the main form, add an extra unbound text box
to the subform. Use its Enter event to save any edits, and set focus to some
other control on the main form, e.g.:
If Me.Dirty Then Me.Dirty = False
Me.Parent![Surname].SetFocus
 
Back
Top