I have a main form with a subform. There are several items on the main form,
but the only control that contains data is a date field and an autonumber
field (meant to assign a unique ID automatically to each new record.) The
date field on the main form may be populated using a popup calendar control
(thank you allen browne) or by the user typing a date directly into the
control, or the user may be happy with the default value I have set for the
field automatically. In this latter case, they may proceed directly to the
subform and start entering subform data without ever really interacting
directly with the main form. If they do not interact with that date field on
the main form, the autonumber field on the main form never changes from the
"autonumber" state and the main form record does not save. I end up with a
bunch of orphaned subform records if they close the entire form/subform
without ever interacting with that date field.
I have set the main form to open with the focus in my date field, and have
tried a few things using the "lost focus" event on this control to force a
save, but I'm not getting anywhere. Could you help me figure out how to
force the main form record to save if the user begins entry on the subform?
Apologies in advance ... I'm learning.
Kerri
Graham Mandeno - 29 Apr 2008 22:48 GMT
Hi Kerri
Use the GotFocus event of the subform.
If Me.NewRecord Then DoCmd.RunCommand acCmdSaveRecord

Signature
Good Luck :-)
Graham Mandeno [Access MVP]
Auckland, New Zealand
>I have a main form with a subform. There are several items on the main
>form,
[quoted text clipped - 26 lines]
>
> Kerri
Graham Mandeno - 29 Apr 2008 22:51 GMT
Hi Kerri
Sorry, I should engage brain before using fingers <g>
A subform control does not have a GotFocus event. Use the Enter event
instead.

Signature
Good Luck :-)
Graham Mandeno [Access MVP]
Auckland, New Zealand
>I have a main form with a subform. There are several items on the main
>form,
[quoted text clipped - 26 lines]
>
> Kerri
Kerri - 29 Apr 2008 23:06 GMT
Thanks for your quick response! I really appreciate it. Unfortunately, it
doesn't seem to be working. If you put the command in the subform "on enter"
event, won't it just save the subform record? These seem to be saving fine
... it is the main form record (parent) that isn't saving. Is there a way to
make the command indicate it is the Main form record that is to be saved?
Thanks for your patience!

Signature
Kerri
> Hi Kerri
>
[quoted text clipped - 32 lines]
> >
> > Kerri
Graham Mandeno - 29 Apr 2008 23:25 GMT
Hi Kerri,
No, the Enter event is associated with the subform *control*, not the form
object that is contained within that control.
The subform control is part of the main form, not the subform, so this code
will execute in the context of the main form.

Signature
Good Luck :-)
Graham Mandeno [Access MVP]
Auckland, New Zealand
> Thanks for your quick response! I really appreciate it. Unfortunately,
> it
[quoted text clipped - 51 lines]
>> >
>> > Kerri
Kerri - 30 Apr 2008 14:00 GMT
I'll give it a try. Thanks again!

Signature
Kerri
> Hi Kerri,
>
[quoted text clipped - 58 lines]
> >> >
> >> > Kerri