Main Form Record Loss


K

Kerri

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
 
Ad

Advertisements

G

Graham Mandeno

Hi Kerri

Use the GotFocus event of the subform.

If Me.NewRecord Then DoCmd.RunCommand acCmdSaveRecord
 
G

Graham Mandeno

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.
 
K

Kerri

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!
--
Kerri


Graham Mandeno said:
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.
--
Good Luck :)

Graham Mandeno [Access MVP]
Auckland, New Zealand

Kerri said:
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
 
G

Graham Mandeno

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.
--
Good Luck :)

Graham Mandeno [Access MVP]
Auckland, New Zealand

Kerri said:
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!
--
Kerri


Graham Mandeno said:
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.
--
Good Luck :)

Graham Mandeno [Access MVP]
Auckland, New Zealand

Kerri said:
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
 
Ad

Advertisements

K

Kerri

I'll give it a try. Thanks again!
--
Kerri


Graham Mandeno said:
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.
--
Good Luck :)

Graham Mandeno [Access MVP]
Auckland, New Zealand

Kerri said:
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!
--
Kerri


Graham Mandeno said:
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.
--
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,
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
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top