Results 1 to 9 of 9

Right-click menu

  1. #1
    pdanes is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Sep 2019
    Posts
    40

    Right-click menu

    I have an extensive set of right-click menus on various textboxes and comboboxes. The menus are dynamic, meaning they change as the contents of the database changes. They are multilevel, and occasionally I need to move an entire set of controls from one popup to another popup.



    The commandbar object has a move method, but the target for the move method, as far as I have been able to determine, is always only a root-level commandbar. I have not figured out a way to move controls to a popup. So far, I am stuck deleting the old control and creating a new one in the proper place. It's not a huge ordeal, but a move would be cleaner. Is there a way to do this?

  2. #2
    Ajax is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    7,554
    not quite sure what you are saying, but have you tried copy/paste? That will also copy the shortcut menu associated with the control

  3. #3
    pdanes is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Sep 2019
    Posts
    40
    The menus are built and managed entirely in VBA, as the database runs, and each control has its own unique right-click menu set. Manual copy/paste of the menus is not an option for me, even if were possible to do that, which I think it is not. Newer versions of Access have done away with the old visual interface to toolbars.

  4. #4
    Ajax is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    7,554
    Manual copy/paste of the menus is not an option for me
    in that case I do not understand what you actually have. rightclick menus are built in the same way they were with older versions of access using commandbars (at least that is what I do). The name of the menu is the added to the shortcut menu bar property of the control

  5. #5
    pdanes is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Sep 2019
    Posts
    40
    This article may explain it a bit: https://docs.microsoft.com/en-us/off...trol-or-report

    Older versions of Access had a graphic interface that allowed building such right-click (=shortcut) menus manually, but that interface has been removed in newer versions. In any case, I could not do it manually - the menus are far too extensive for manual work, and must adapt dynamically as the database's content changes.

  6. #6
    Ajax is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    7,554
    that article is the way I do it.

    I avoid them but if you want to use macros, see this link https://support.office.com/en-gb/art...0-3309aebf8a1a

    So really not sure what you are asking, I thought you were asking about moving a shortcut for a control to a popup form. If you need different versions depending on the data you can use vba to swap shortcut menus around and if they have to be dynamic, you can create them on the fly, it's not difficult, I use a function which loops through a case statement. So what is the relevance of the old way of creating menus using a GUI? It no longer exists.

  7. #7
    pdanes is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Sep 2019
    Posts
    40
    There is no relevance of the old way, except that you referred to it, when you suggested a manual copy/paste in #2, and said that command bars are built the same way as they were in old versions in #4, which they are not.

    I have all these menus built and dynamically rearranged with VBA. All this works, except that when an item is (for instance), the second item in a third-level popup, and I want to move it down to become the seventh item on a fourth-level popup, I must delete the existing command button from the third-level popup and create a new command button identical to the old one in the seventh position on the fourth-level popup. That requires several lines of code. Since the object model of the command bars contains a Move method, I thought that I could use this method to simply relocate an existing command button. However, it seems that I can only relocate it to the root level of a command bar, not further down to a nested popup within a command bar. THAT is what I am asking about - if the Move method can be used to relocate a command button to a lower-lever popup, rather than only the top level of the command bar.

  8. #8
    Ajax is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    7,554
    when you suggested a manual copy/paste in #2
    I was referring to the shortcut menu bar property of a control, not within a shortcut menu. your phrase 'I have not figured out a way to move controls to a popup' led me down the wrong path.

    So to answer your question I don't know of a way using the move option as you require, however if you haven't already done it, I would have thought you could create a sub or function with parameters to 'delete the existing command button from the third-level popup and create a new command button identical to the old one in the seventh position on the fourth-level popup' which would be called with one line.

    Sorry I can't be more help, good luck with your project

  9. #9
    pdanes is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Sep 2019
    Posts
    40
    Sorry, my initial post was a bit cryptic. Yes, I now do it via functions and subs, in order to encapsulate the individual steps. I do not yet have it as tidy as I want, and part of my efforts to clean it up were to see if maybe I was overlooking something in the Move method, where one built-in method might substitute for a number of lines of VBA code, including loops, when I need to reposition everything in a particular popup. I was hoping that maybe I could Move the entire popup with all its command buttons to another place with one command, rather than a loop that steps through deleting and recreating each item. But it's fast enough now - the number of items that must be so repositioned in one call is usually quite low, an average of 2 to 5, very occasionally a few more. Speed and functionality are not the issue - just always trying to make things better, and learn a bit in the process. Thank you for responding.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Right click menu with arrow
    By loy in forum Programming
    Replies: 9
    Last Post: 05-15-2017, 12:51 PM
  2. Simple right-click menu example
    By pkstormy in forum Code Repository
    Replies: 1
    Last Post: 02-03-2015, 06:49 PM
  3. right click context menu
    By rpeare in forum Programming
    Replies: 8
    Last Post: 10-27-2014, 11:16 AM
  4. Copy and Paste in right click menu
    By chriscardwell06 in forum Access
    Replies: 1
    Last Post: 12-27-2013, 09:15 AM
  5. On click menu items do not work
    By mrk68 in forum Access
    Replies: 1
    Last Post: 03-23-2009, 07:29 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Tech Forums: Microsoft Office Forums