I am trying to loop through the controls on a subform and take all the values from the text boxes and set the same named text boxes on the main form to the same value. I would like to do it by using a variable
The code below gives me an error referencing Me.Parent!strParentControlName because it is referenceing the control as "strParentControlName" instead of as the variable strParentControlName
How do I get Me..Parent!strParentControlName to use strParentControlName as a variable.
Private Sub Form_Click()
Dim ctlCurrent As Control
Dim strParentControlName As String
For Each ctlCurrent In Me.Controls
If ctlCurrent.ControlType = acTextBox Then
strParentControlName = ctlCurrent.Name
Me.Parent!strParentControlName = ctlCurrent.value
End If
Next ctlCurrent
End Sub
The code below gives me an error referencing Me.Parent!strParentControlName because it is referenceing the control as "strParentControlName" instead of as the variable strParentControlName
How do I get Me..Parent!strParentControlName to use strParentControlName as a variable.
Private Sub Form_Click()
Dim ctlCurrent As Control
Dim strParentControlName As String
For Each ctlCurrent In Me.Controls
If ctlCurrent.ControlType = acTextBox Then
strParentControlName = ctlCurrent.Name
Me.Parent!strParentControlName = ctlCurrent.value
End If
Next ctlCurrent
End Sub