Acces 2013: Displaying first record in subforms

Rick Danger
Rick Danger used Ask the Experts™
on
In the attached example, which I actually got from another expert, there a 3 subforms used in a master form "F__PPSAccounts". When I open this form it shows the first record of subform "S_ContractYears" and the first record of "S_Guarantees". But the other subform "S_RevSharePmts" doesn't show any records, even though for the combination of the other 2 subforms it should show 4 records. It is not until you click on the second record on "S_Guarantees" then back to the first record that it displays and records.

I need the 3 forms to show the relevant records as soon as the form is open. So in the attached example, when you open the
"F__PPSAccounts" form it should show:
2 records in "S_ContractYears" (416 and 417)
2 records in "S_Guarantees" (15 and 16)
4 records in "S_RevSharePmts" (27, 28, 29 and 34)

It's OK when you click on the second record in the "S_ContractYears" subform, but I need it to be correct as soon as you open the main form please
Form-Parent-Child-Grandchild--1-.accdb
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Dale FyeOwner, Dev-Soln LLC
Most Valuable Expert 2014
Top Expert 2010

Commented:
From my iPad, so cannot open your db.

Is this 3rd subform linked in a master-child relationship to the main form?  If so, how

If not, what is the query you are using for the subform.  If you are actually using a query in this subform, that is linked to the current record in the two other subforms, then you should have code in the Current event of those two other subforms with requeries the recordset in the 3rd subform.

Dale

Author

Commented:
The 2nd subform is linked to the first, and the 3rd is linked to the 2nd.
The 2nd and 3rd subforms have tables as their recordsource

The OnCurrent Event on the 1st subform does this:
Me.Parent![S_RevSharePmts].Requery
Me.Parent![sfS_Guarantees].Requery

The 2nd subform has its Master field as: [S_ContractYears].Form![ContractID] (from the 1st subform)
and its Child field as: ContractID
Its OnCurrent Event does this: Me.Parent![S_RevSharePmts].Requery

The 3rd subform has its Master field as: [sfS_Guarantees].Form![GuaranteeID] (from the 2nd subform.
and its Child field as: GuaranteetID
Its does not have an OnCurrent Event.
Top Expert 2016
Commented:
try this
in the Load event of form "F__PPSAccounts", requery the subform "S_RevSharePmts"

private sub form_load()
me.S_RevSharePmts.requery
end sub
Top Expert 2016

Commented:
another option is to use the current event of the form "F__PPSAccounts", depending on the way you are using the main form..

private sub form_current()
me.S_RevSharePmts.requery
end sub

Author

Commented:
Thanks for taking the time!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial