Control Change Toolbar
acCmdChangeToCheckBox, acCmdChangeToComboBox, acCmdChangeToImage, acCmdChangeToLabel, acCmdChangeToListBox, acCmdChangeToOptionButton, acCmdChangeToTextBox, acCmdChangeToToggleButton
This routine allows you to display a toolbar to assist in the design of a Form or Report. There are a number of steps required to ensure this example works.
- Create a toolbar called "ChangeControlToolbar"
- Add the required buttons to the toolbar
- Name the buttons as appropriate. Set the on action property to "=ChangeControl("Checkbox")" etc.
- Add the ChangeControls function to a module
- Display the Toolbar "ChangeControlToolbar" when in the design of a form or report
'***************** Code Start *******************
'This code was originally written by Terry Wickenden.
'It is not to be altered or distributed,
'except as part of an application.
'You are free to use it in any application,
'provided the copyright notice is left unchanged.
Function ChangeControl(strType As String)
'Accepts a string of type of control to be changed to
'Needs to run from a toolbar
Dim strCheck As String
Dim intHold As Integer
On Error GoTo ErrHandler
strCheck = UCase(strType)
Select Case strCheck
Case "CHECKBOX"
intHold = acCmdChangeToCheckBox
Case "COMBO"
intHold = acCmdChangeToComboBox
Case "IMAGE"
intHold = acCmdChangeToImage
Case "LABEL"
intHold = acCmdChangeToLabel
Case "LISTBOX"
intHold = acCmdChangeToListBox
Case "OPTION"
intHold = acCmdChangeToOptionButton
Case "TEXTBOX"
intHold = acCmdChangeToTextBox
Case "TOGGLE"
intHold = acCmdChangeToToggleButton
End Select
DoCmd.RunCommand intHold
Exit Function
ExitSub:
ErrHandler:
MsgBox "The command is not available at present"
Resume ExitSub
End Function
'****************** Code End ********************