KySoto

RenameControlsFromControlSource

Jun 26th, 2018
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Public Sub RenameControlsFromControlSource(argObjectName As String, argObjectType As AcObjectType)
  2. Dim o As Object
  3. Dim c As Control
  4. If argObjectType = acForm Then
  5.     DoCmd.OpenForm argObjectName, acDesign
  6.     Set o = Forms(argObjectName)
  7. ElseIf argObjectType = acReport Then
  8.     DoCmd.OpenReport argObjectName, acViewDesign
  9.     Set o = Reports(argObjectName)
  10. Else
  11. Exit Sub
  12. End If
  13. If o.RecordSource & "" <> "" Then
  14.     For Each c In o.Controls
  15.         If c.ControlType = acTextBox Then
  16.             If c.Name <> "txtAppPath" Then
  17.                 If c.ControlSource & "" <> "" Then
  18.                     c.Name = "txt" & c.ControlSource
  19.                 End If
  20.             End If
  21.         ElseIf c.ControlType = acOptionGroup Then
  22.             If c.ControlSource & "" <> "" Then
  23.                 c.Name = "rad" & c.ControlSource
  24.             End If
  25.         ElseIf c.ControlType = acCheckBox Then
  26.             If c.ControlSource & "" <> "" Then
  27.                 c.Name = "chk" & c.ControlSource
  28.             End If
  29.         End If
  30.     Next
  31. End If
  32. End Sub
Advertisement
Add Comment
Please, Sign In to add comment