Autofill a subform field from a main form field

Matt Parker picture Matt Parker · Jan 30, 2010 · Viewed 7.2k times · Source

I have a form with two subforms, both of which are continuous. Each form has a field to accept the name of the person who created the record. Almost every time, the same person will be creating all of the records, so it would be really convenient if the fields would autofill once the main record has been set.

I've tried several approaches to this, but none seem to work quite right (e.g., the first of the continuous forms won't autofill because it came into existence alongside the main record). This is Access 2003.

Thanks in advance for your help, and let me know if I can clarify the situation for you at all.

Answer

David Walker picture David Walker · Jan 30, 2010

OnCurrent, OnClick, etc...

If IsNull(Me.MyField) or Me.MyField = "" Then

  Me.MyField = Me.Parent.MyRelatedField

End If