Subform data not saving when focus moves to parent

G

google

I have a form with several subforms. Users enter the data, then on the
parent there is a command button that runs code to generate a .pdf
document from a report based on the data they are working with. If a
user enters data in a subform, then directly clicks the command button
on the parent form, the data in the subform is not included in their
document. I THOUGHT that as soon as focus left the subform, any
pending changes to the data were saved. In fact, in googling "dirty"
and "subform", the general feedback that I've seen suggests that you
don't need to test for a dirty subform, since it will never be dirty
since it's saved by the time the code for the command button is
executed. But that is clearly not what I'm experiencing.

When this does happen, all I have to do is move their cursor to another
record or into another subform, and THEN the data saves. But not when
moving directly from editing a record in a subform, to a command button
on the parent. Any ideas why the subform is not saving when I move to
the parent? If I do have to test for dirty subforms, that is fine, but
one question I have: if I test for dirty subforms, find any, then do a
save record command, does that automatically save the records in all
the subforms? I'm not aware of any way to direct WHAT is being saved.
(?)
 
V

Van T. Dinh

What you wrote (the CurrentRecord in Subform is saved when the Focus is
moved from the Subform to the MainForm, e.g. Focus in the Subform and the
CommandButton on the Subform is activated) is true. However, there may be
timing issues and the update may still be in cache pending so the Report
(which gets the data from the Table) may not pick up the new (or being
edited) Records ...

A a test, try moving athe Focus from the Subform to the MainForm, wait about
5 seconds and then activate the Command Button and see if the new (or being
edited)Record (from the Subform) is picked up.

If this is the case, you may like to use the Idle method with dbRefreshCache
option before the OpenReport statement in the CommandButton_Click Event ...
 

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