Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2006
    Posts
    6

    Unanswered: Adding a menu on opening the application and removing it when closing the application

    Hi,

    I would like to have a drop down menu similar to the built-in 'File', 'Edit' menus for my access 2002 project. This menu should be seen only for my application. I mean when the user opens access he should not be seeing it...however when he opens my application he should be seeing the menu.

    The menus name would be "Add/Delete Items" and it should have the following list "Add Items To Shell", "Delete Items From Shell". I have two forms "AddItemsToShells", "DeleteItemsFromShell". When the user Clicks on the 'Add Items To Shell' , the corresponding form should be open.

    I tried to do it using the 'Customize' option in the Tools menu...but its visible when we open access too . I tried to do it programmatically but it was floating and the user was able to close it. I need something very similar to File, Edit menus...How do I acheive this. Also this menu should not be allowed to remove while the application is open.

    Do we have any On Application Start and On application Close events in access 2002.

    Any help is appreciated.

    Thanks,
    Jyothsna

  2. #2
    Join Date
    Oct 2006
    Posts
    6
    I figured out how to add the pop up menu to the built-in "Menu Bar"

    However I am not able to get the corresponding forms open when the user clicks on the "Add Items To Shells", "Delete Items To Shells"

    Following is my code
    frmAddItemsToRcreates is the name of the form that I want to open on the click of "Add Items To Rcreates"
    I know I am doing something wrong onAction...but not sure how to fix it. I am calling this function on the Form_load event of the start up form. Any help is really appreciated.

    Sub AddNewCB()
    Dim cbar As CommandBar, objCommandBarComboBox As Office.CommandBarComboBox
    Dim objCommandBarPopup As CommandBarPopup
    Dim objCommandBarButton As CommandBarButton
    On Error GoTo AddNewCB_Err


    For Each cbar In CommandBars
    If cbar.Name = "Menu Bar" Then
    Set cbar = Application.CommandBars("Menu Bar")

    Set objCommandBarPopup = cbar.Controls.Add(msoControlPopup)

    With objCommandBarPopup
    .Caption = "Add/Delete Items"

    Set objCommandBarButton = .Controls.Add(msoControlButton)
    With objCommandBarButton
    .Caption = "Add Items To Rcreates"
    .Style = msoButtonCaption
    End With
    objCommandBarButton.OnAction = "!frmAddItemsToRcreates"


    Set objCommandBarButton = .Controls.Add(msoControlButton)
    With objCommandBarButton
    .Caption = "Add Items To Orders"
    .Style = msoButtonCaption
    .OnAction = "!frmAddItemsToOrders"
    End With
    End With

    Exit Sub
    End If
    Next cbar



    Exit Sub
    AddNewCB_Err:
    MsgBox "Error " & Err.Number & vbCr & Err.Description
    Exit Sub
    End Sub

    Sub DeleteCB()
    Dim cbar As CommandBar
    Dim cbarpopup As CommandBarPopup
    For Each cbar In CommandBars
    If cbar.BuiltIn = True And cbar.Name = "Menu Bar" Then
    cbar.Controls("Add/Delete Items").Delete
    Exit Sub
    End If
    Next cbar
    End Sub
    Last edited by Jyothsna; 12-13-06 at 17:18.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •