I cannot figure out how to set the name of a label control to the name of it's parent ControlSource.
here is then code I have for setting everything.
Thanks
John Fuhrman
here is then code I have for setting everything.
Code:
For Each ctl In frm.Section("Detail").Controls
' Debug.Print ctl.Name, ctl.ControlSource
' Name specific controls according to their type
' making sure the control has not already been named
Select Case ctl.ControlType
Case acTextBox
' If Left(ctl.Name, 3) = "txt" Then
Debug.Print "Renaming " & ctl.Name & _
" to " & ctl.ControlSource
' ctl.Name = "txt" & ctl.ControlSource
ctl.Name = ctl.ControlSource
' End If
Case acComboBox
' If Left(ctl.Name, 3) = "cbo" Then
Debug.Print "Renaming " & ctl.Name & _
" to " & ctl.ControlSource
' ctl.Name = "cbo" & ctl.ControlSource
ctl.Name = ctl.ControlSource
' End If
Case acListBox
' If Left(ctl.Name, 3) = "lst" Then
Debug.Print "Renaming " & ctl.Name & _
" to " & ctl.ControlSource
' ctl.Name = "lst" & ctl.ControlSource
ctl.Name = ctl.ControlSource
' End If
Case acCheckBox
' If Left(ctl.Name, 3) = "chk" Then
Debug.Print "Renaming " & ctl.Name & _
" to " & ctl.ControlSource
' ctl.Name = "chk" & ctl.ControlSource
ctl.Name = ctl.ControlSource
' End If
Case acLabel
Set ctlLabel = ctl
If Left(ctl.Name, 3) = "lbl" Then
Debug.Print "Renaming " & ctl.Name & _
" to " & "lbl_" & ctl.ControlSource
ctl.Name = "lbl_" & ctl.ControlSource
End If
End Select
Next ctl
Thanks
John Fuhrman