Access.2007.VBA.Bibl..

(John Hannent) #1
Special case for lines whose default name is “Line” or “Option” (same first three letters as the stan-
dard prefix).

If Left(pstrOldCtlName, 3) = strPrefix And _
Left(pstrOldCtlName, 6) <> “Option” And _
Left(pstrOldCtlName, 4) <> “Line” Then
Exit Function
Else
pstrNewCtlName = strPrefix _
& StripChars(pstrOldCtlName)
End If

pintRenameFail = True
Do While pintRenameFail
pintRenameFail = False
pintReturn = MsgBox(“Rename “ & _
DLookup(“[ControlTypeName]”, _
“zLNCtblControlType”, “[ControlType] = “ _
& ctl.ControlType) & “ control currently named “ _
& pstrOldCtlName & “ to” & vbCrLf _
& pstrNewCtlName & “?”, vbYesNo + vbQuestion _
+ vbDefaultButton1, _
“Rename control”)
If pintReturn = vbYes Then
If blnTag = True Then ctl.Tag = ctl.ControlName
ctl.ControlName = pstrNewCtlName
ElseIf pintReturn = vbNo Then
pstrNewCtlName = _
InputBox(“Modify new control name”, _
“Rename control”, pstrNewCtlName)
ctl.ControlName = pstrNewCtlName
End If
Loop

ErrorHandlerExit:
Exit Function

ErrorHandler:

If the proposed control name is already in use, return to the renaming dialog.

pintRenameFail = True
If Err.Number = 2104 Then
MsgBox “There is another control named “ & _
pstrNewCtlName & “; please try again”, , _
“Control Name Used”
pstrNewCtlName = pstrNewCtlName & “1”
Else
AddInErr Err

Part III Adding More Functionality to Office

Free download pdf