Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Togglebutton on Toolbar

Status
Not open for further replies.

poliv

Programmer
Jun 3, 2000
48
0
0
US
I want to put a custom togglebutton on a toolbar in Access 2003.
I don´t see any option to do that and I am not sure if this is possible.
Need help

Poliv


 
I think you have to create it programmatically. Here's some code that will do that for you.
Code:
    Dim cbcControl As CommandBarControl

'***************************************************
'*  If the button does NOT exist, then create it.  *
'***************************************************
    
    On Error Resume Next
    
    Set cbcControl = CommandBars("NameOfTheCommandBar").Controls("NameOfYourControl")
    
    '**********************************************
    '*  If the button doesn't exist, then add it  *
    '**********************************************
    
    If (Err.Number = 5) Then            'IFT, button doesn't exist
    
        On Error GoTo ErrHandler
        
        Set cbcControl = CommandBars("NameOfTheCommandBar").Controls.Add(msoControlButton)
    
        With cbcControl
            .Caption = "Whatever"
            .Tag = "Whatever"
            .OnAction = "NameOfFunctionToCall"
            .Visible = True
            .BeginGroup = True
            .DescriptionText = "Whatever"
        End With
    
    End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top