I have multiple copies of a subA on a form. Each one has a unique name subAA, subAB, .... I am trying to populate text fields on each form based on the contents of a class. I can find the subforms in the controls collection but I can't figure out how to reference the text boxes on each form.
Any suggestions?
Also, if there's a smarter way to get the control using its name, that would also be better than looping through all of them.
Any suggestions?
Also, if there's a smarter way to get the control using its name, that would also be better than looping through all of them.
Code:
Private Sub DisplaySummary(subFormName As String, totals As clsTotals)
Dim subControl As Control
For Each subControl In Me.Controls
If subControl.name = subFormName Then Exit For
Next subControl
If subControl.name = subFormName Then
subControl!Form!lblTotals = totals.MyTitle
subControl.Form.txt12Month = totals.MoneyTrailing12
subControl.Form.txtLastYear = totals.MoneyLastYear
subControl.Form.txtPriorYear = totals.MoneyPriorYear
subControl.Form.txtYTD = totals.MoneyYTD
End If
End Sub