简体   繁体   中英

Autofill a subform field from a main form field

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 (eg, 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.

OnCurrent, OnClick, etc...

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

  Me.MyField = Me.Parent.MyRelatedField

End If

It may be best to set the default value of the control in the after update event for the control. This means that it will fill with whatever the previous value was.

Me.SomeText.DefaultValue= """" & Me.SomeText & """" ''Text

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM