How set default value in subform column?

  • Thread starter Thread starter David
  • Start date Start date
D

David

I have a subform that displays records related to the
record on my main form. Both tables contain a 'department'
column. When a new record is added on the subdform, I want
the department from the main form to appear as the default
department in the subform record. I looked at the events
on the subform column and none appear to be right for
setting this value. This default is only to be set when
adding a new record. My subform is like a datasheet with
repeated rows which can be scrolled.
 
put the following in the subform's BeforeInsert event:

Me!Department = Me.Parent!Department

having said that, i have to question your table design. if
the parent record has a "department" field, then why does
that field appear again in the child record? if the value
MAY be different in the child record, then it makes sense;
but if the child record "department" value always matches
that in the parent record, probably you should take that
field out of the child record.

hth
 
Thanks for the suggestion.

The department in the parent record is a default which
must be copied into the child record - but can be changed.
95% of the time it wont be changed, but I must allow for
it.
- David
 
Back
Top