I don't understand the problem that the sub-form is empty?
I mean, there is no need/reason to add sub-form records until the user
edits, or needs one?
Virtually 90% of all my quires are left joins. A left join means that
records will appear in reports EVEN if a child record is not present when
doing a join.
Also, when you state that you are moving to a new record, are you talking
about the main form, or the sub-form?
I also don't see why the fact that the sub-form is empty is a problem? You
should not be adding sub-records until the user actually edits the sub-form.
And, in fact, when the cursor moves to the sub-form, the main form is
written to disk anyway for you. (thus, you probably don't need my me.refresh
idea anyway).
Are you trying to add a sub-form/child record from code in the main form?
(and do you *really* need/want to do this?. As mentioned, there is NO REASON
to create these child record needlessly...is there?).
There is no question that you MUST FIRST write out the main record BEFORE
you attempt to add, or edit a child record. Your code that sets the default
key should do the trick here, and that should cause the main record to be
dirtied. At that point, you are free to add/edit child records...but
certainly no child records should exist until the main record is edited (and
further, as mentioned, NO CHILD records need to be added until the user
actually edits the sub-form).
In addtion, you are talking about a form-load event, and then you are
talking about a commadn to move to a new reocrd. When you move to a new
record, the form load event is not triggered. Perahps you need to add the
"set default" code to the buttion that moves to a new record?
--
Albert D. Kallal (MVP)
Edmonton, Alberta Canada
No************@msn.com http://www.attcanada.net/~kallal.msn