Kamis, 04 April 2013

[MS_AccessPros] CommandBar

 

Dear All,

I try to implement the next code for creating my own menu the problem the when i type
Dim cmb as commandbar
the popup menu containing these command does not contains "commandbar"
what it the problem?
is there a missing refrence? how i can get it

thanks for your usual support.

the complete code is :
Option Compare Database
Option Explicit

----------------------------------------------------------   
Public Function CreateCMenu()
On Error Resume Next
    CommandBars("MyContext").Delete
    Dim cmb As CommandBar
    Set cmb = CommandBars.Add("MyContext", _
               msoBarPopup, False, False)
    
        With cmb
            .Controls.Add msoControlButton, _
                      21, , , True  ' Cut
            .Controls.Add msoControlButton, _
                      19, , , True  ' Copy
            .Controls.Add msoControlButton, _
                      22, , , True  ' Paste
        End With
End Function
   
Public Function CreateCMenu1()
On Error Resume Next
    CommandBars("MyContext1").Delete
    Dim cmb     As CommandBar
    Dim cmbBtn1 As CommandBarButton
    Dim cmbBtn2 As CommandBarButton
    Dim cmbBtn3 As CommandBarButton
    
    Set cmb = CommandBars.Add("MyContext1", _
               msoBarPopup, False, False)
    
        With cmb
            Set cmbBtn1 = .Controls.Add(msoControlButton, _
                                    , , , True)
            With cmbBtn1
                .Caption = "My Button 1"
                .OnAction = "=fncOnActionBtn1()"
            End With
            
            Set cmbBtn2 = .Controls.Add(msoControlButton, _
                                    , , , True)
            With cmbBtn2
                .Caption = "My Button 2"
                .OnAction = "=fncOnActionBtn2()"
            End With
            
            Set cmbBtn3 = .Controls.Add(msoControlButton, _
                                    , , , True)
            With cmbBtn3
                .Caption = "My Button 3"
                .OnAction = "=fncOnActionBtn3()"
                .BeginGroup = True
                .FaceId = 59
            End With
        End With
End Function
   
Public Function fncOnActionBtn1()
    MsgBox "Button 1", vbInformation
End Function
   
Public Function fncOnActionBtn2()
    MsgBox "Button 2", vbInformation
End Function
   
Public Function fncOnActionBtn3()
    MsgBox "Button 3", vbInformation
End Function
----------------------------------------------------------

__._,_.___
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (1)
Recent Activity:
.

__,_._,___

Tidak ada komentar:

Posting Komentar