Default value on a Subform

N

NevilleT

Have been fiddling with this for about a week. I have a main form which is a
datasheet. There is a subform which is a continuous form. Main form
displays budget line by line and subform displays expenditure items for that
account code.

I am trying to put a default value for the account code in the new record on
the subform. If I set the default to the main form (datasheet) it always
picks up the first account code value. I even tried doing it with code.

Me.txtAccountCode.DefaultValue =
[Forms]![frmExpenditure]![subGeneric].[Form]![frmExpenditureBudgetSub].[Form]![cmbAccountCode]

Just to explain, I am using Allen Browne's suggestion of having a generic
subform managed through a tab control hence the
[Forms]![frmExpenditure]![subGeneric].

I thought I could try and capture the value of the parent child link to the
subform but have not been able to come up with a way to find that using VBA.
Can anyone make a suggestion as to how to ensure the default value for the
subform does not always correspond to the first record on the datasheet?
 
Top