S
Stuart McGraw
I haven't been able to figure this out and would
appreciate some help...
I have two tables, both with autonumber primary
keys, and linked in a conventional master-child
relationship. I've created forms for both those
tables, and inserted the child table form into the
master table form as a subform. It works just as
it is supposed to, in that I can create a new master
record, and then add detail records.
But... all the columns in the master table have
default values so I don't really have to enter
anything in the master table. (It's only real purpose
is to provide groups of detail records.) But, of course,
it I go to a new record, then try to enter a detail
record, without having created a master
record first, Access complains about no value
in the child table field that links to the master
table. What I want to do, is to be able to go
to the subform table, create a record, and have
Access create the necessary master record (if
none exists already) before trying to save the
detail record.
In the Before_update procedure in the child form
I tried modifying the master record (Me.parent!-
[somefield] = <innocuous-value>, causing it
to be created. Then I try to save it be doing
Me.parent.dirty = false. This causes a 2115 error
from Access ("The macro or function set to the
BeforeUpdate [..] property is preventing Access
from saving the data...") I tried many different
permutations of this without finding the right
way... (Including adding the master record with
dao -- but the form doesn't know anything about
it so doesn't display it. Also tried adding
the record with dao, on the form's recordset but
get an error from that.)
Is there some way I can force the creation of a
parent record (if none exists) before saving the
child record?
I hope this is understandable -- if not please tell
me and I'll try to clarify...
appreciate some help...
I have two tables, both with autonumber primary
keys, and linked in a conventional master-child
relationship. I've created forms for both those
tables, and inserted the child table form into the
master table form as a subform. It works just as
it is supposed to, in that I can create a new master
record, and then add detail records.
But... all the columns in the master table have
default values so I don't really have to enter
anything in the master table. (It's only real purpose
is to provide groups of detail records.) But, of course,
it I go to a new record, then try to enter a detail
record, without having created a master
record first, Access complains about no value
in the child table field that links to the master
table. What I want to do, is to be able to go
to the subform table, create a record, and have
Access create the necessary master record (if
none exists already) before trying to save the
detail record.
In the Before_update procedure in the child form
I tried modifying the master record (Me.parent!-
[somefield] = <innocuous-value>, causing it
to be created. Then I try to save it be doing
Me.parent.dirty = false. This causes a 2115 error
from Access ("The macro or function set to the
BeforeUpdate [..] property is preventing Access
from saving the data...") I tried many different
permutations of this without finding the right
way... (Including adding the master record with
dao -- but the form doesn't know anything about
it so doesn't display it. Also tried adding
the record with dao, on the form's recordset but
get an error from that.)
Is there some way I can force the creation of a
parent record (if none exists) before saving the
child record?
I hope this is understandable -- if not please tell
me and I'll try to clarify...