Access.2007.VBA.Bibl..

(John Hannent) #1
Else
AddInErr Err
Resume ErrorHandlerExit
End If

Resume Next

End Function

Public Function ControlCA(ctl As Access.Control, _
strPrefix As String, blnTag As Boolean) As Integer

Does group renaming of all controls with captions on a form or report.

On Error GoTo ErrorHandler

Dim strCaption As String

pstrOldCtlName = ctl.ControlName
strCaption = ctl.Caption

If Left(pstrOldCtlName, 3) = strPrefix Then
Exit Function
ElseIf strCaption <> “” Then
If Left(strCaption, 3) = “frm” Then
pstrNewCtlName = strPrefix & _
Mid(StripChars(strCaption), 4)
ElseIf Left(strCaption, 4) = “fsub” Then
pstrNewCtlName = strPrefix & _
Mid(StripChars(strCaption), 5)
Else
pstrNewCtlName = strPrefix & _
StripChars(strCaption)
End If
ElseIf strCaption = “” Then
If Left(pstrOldCtlName, 3) = “frm” Then
pstrNewCtlName = strPrefix & _
Mid(StripChars(pstrOldCtlName), 4)
ElseIf Left(pstrOldCtlName, 4) = “fsub” Then
pstrNewCtlName = strPrefix & _
Mid(StripChars(pstrOldCtlName), 5)
Else
pstrNewCtlName = strPrefix & _
StripChars(pstrOldCtlName)
End If
End If

If Right(pstrNewCtlName, 12) = “SubformLabel” Then
pstrNewCtlName = Left(pstrNewCtlName, _
Len(pstrNewCtlName) - 12)

Part III Adding More Functionality to Office

Free download pdf