UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> How To Create "right Click" Menus In Accdr, Access 2010    
 
   
soldier
post May 26 2013, 09:55 PM
Post#1



Posts: 102
Joined: 26-November 03



Greetings,
Here is what I posted in the forum "Access Runtime - deployment and packaging". When I did not get any response I have assumed that I used the wrong forum. I will post here.
-------------------
For two days I have been searching for help on this and have come up dry.
I have created an accdr file but I cannot right click on a field to copy/paste. From all of my research it seems like I can use macros or VBA to create a menu in runtime. I have tried unsuccessfully to make that work and would really appreciate it if someone could direct me to an article or site that can explain how to do this in simple terms. If I had my choice I would prefer to do this in VBA.
HAs always, I appreciate the quality support that users of UtterAccess offer to greenhorns like me.
Blessing
Go to the top of the page
 
pere_de_chipstic...
post May 27 2013, 02:50 AM
Post#2


UtterAccess Editor
Posts: 10,522
Joined: 8-November 07
From: South coast, England


Hi Ken
IRC, the accdr file extension disables built in menus and short cuts. You will need to create your own custom short cut menus - check the Access help files for custom short cut menus.
hth
Go to the top of the page
 
Peter46
post May 27 2013, 04:07 AM
Post#3


UtterAccess VIP
Posts: 7,489
Joined: 3-October 05
From: Oadby Leics, UK


There is no longer any simple way of creating shortcut menus.
It used to be done (pre A2007) through a simple UI dialog but that is no longer possible.
It has to be done in VBA now.
See this article for details.
http://msdn.microsoft.com/en-us/library/office/ff194247.aspx
(Bernie - you must have a different version of Help to me if you can find anything on this topic there (:-) )
Go to the top of the page
 
pere_de_chipstic...
post May 27 2013, 04:23 AM
Post#4


UtterAccess Editor
Posts: 10,522
Joined: 8-November 07
From: South coast, England


Hi Peter
had about 40 hits from the Access help - most (all?) were links to other web sites, Including this one, which I've used successfully and doesn't need VBA.
Cheers
Go to the top of the page
 
Peter46
post May 27 2013, 04:38 AM
Post#5


UtterAccess VIP
Posts: 7,489
Joined: 3-October 05
From: Oadby Leics, UK


This is what I get from Access Help...(see attached)
Is there some Help setting that I'm missing out on?
The specific link you supplied was for A2007 , when macros looked the same as in earlier versions.
Have you created new shortcut menus this in A2010 (the poster's version)?
Attached File(s)
Attached File  Capture8.PNG ( 58.3K )Number of downloads: 14
 
Go to the top of the page
 
pere_de_chipstic...
post May 27 2013, 04:58 AM
Post#6


UtterAccess Editor
Posts: 10,522
Joined: 8-November 07
From: South coast, England


Hi Peter
I'm not aware of any special settings for the A2010 help file - I've just opened it as I usually use A2007, - however my A2010 help does give a number of specific custom short cut menu links, which aren't in your image iconfused.gif
The method in the link I posted creates two macro's, and while I have not created them in 2010 they do run in 2010 and hence the method would seem perfectly valid wary.gif
Go to the top of the page
 
TheSmileyCoder
post May 27 2013, 02:18 PM
Post#7


UtterAccess VIP
Posts: 1,526
Joined: 19-January 12
From: Denmark, Copenhagen


Hi Ken
This is an example of a sub that creates a commandbar that gives the user the basic Cut/Copy/Paste. The sub is run as part of my startup procedure for the client.
CODE
Public Sub CreateRigthClickBar()
    Dim cmbRC As CommandBar
    Dim cmbButtonCopy As CommandBarButton
    Dim cmbButtonCut As CommandBarButton
    Dim cmbButtonPaste As CommandBarButton
    Dim strBarName As String
    strBarName = "CustomRightClick"
    
    On Error Resume Next
    CommandBars(strBarName).Delete
    On Error GoTo 0
    
    Set cmbRC = CommandBars.Add(strBarName, msoBarPopup, False)
    
    Set cmbButtonCopy = cmbRC.Controls.Add(msoControlButton, 21)
    Set cmbButtonCut = cmbRC.Controls.Add(msoControlButton, 19)
    Set cmbButtonPaste = cmbRC.Controls.Add(msoControlButton, 22)
    
'Cleanup
    Set cmbRC = Nothing
        
    Set cmbButtonCopy = Nothing
    Set cmbButtonCut = Nothing
    Set cmbButtonPaste = Nothing
End Sub

It requires a reference set to the office library, but it could be converted to late bound I am sure. Now for those controls where I want this commandbar available I set the "shortcut menu bar" property to be equal to the name of my commandbar, in this example the name is "CustomRightClick". Using the built in functions has great advantages, among others that access will automatically enable/disable the buttons based on what is possible, for example if no text is selected then cut/copy will not be available.
I have NOT tested this for runtime, since I don't use that.
For more information on right click commandbars you can try to watch my tutorial on youtube Treeview in MS Access: Part 5 - Right Click CommandBars . The approach is slightly different than that outlined above, but still think you could find it useful.
Go to the top of the page
 
damian.green
post Dec 31 2019, 07:25 PM
Post#8



Posts: 61
Joined: 24-October 18



Thanks for the code. I made the following tweeks to reduce what I needed to type to add a new button. Note the fewer Dim at the top and Set in the clean up section.

Public Sub CreateRigthClickBar()
'http://www.UtterAccess.com/forum/lofiversion/index.php/t2004634.html
'MenuCreator database to find the codes
'https://access-programmers.co.UK/forums/showthread.php?t=197363
'Office Fluent User Interface Control Identifiers
'https://www.microsoft.com/en-us/download/confirmation.aspx?id=36798
'Idea on how to tighten up the code.
'https://www.youtube.com/watch?v=G0OetcYcbM8

'Step 1: Modify the right click menu option below with # from Office Fluent User Interface Control Idetifiers.
'Step 2: Run this macro from VBA.
'Step 3: Save
'Step 4: Open the form and if this is already a Shortcut Menu Bar (Property Sheet > Other) it should be working.

Dim cmbRC As CommandBar
Dim cmbb As CommandBarButton
Dim strBarName As String

strBarName = "FormRightClick"

On Error Resume Next
CommandBars(strBarName).Delete
On Error GoTo 0

Set cmbRC = CommandBars.Add(strBarName, msoBarPopup, False)

Set cmbb = cmbRC.Controls.Add(msoControlButton, 640)
cmbb.Caption = "Filter by Selection"
Set cmbb = cmbRC.Controls.Add(msoControlButton, 11761)
cmbb.Caption = "Filter Menu"
Set cmbb = cmbRC.Controls.Add(msoControlButton, 605)
cmbb.Caption = "Clear Filters"
Set cmbb = cmbRC.Controls.Add(msoControlButton, 210)
cmbb.Caption = "Sort A-Z"
'The line the BeginGroup draws is one command below were you want it.
cmbb.BeginGroup = True
Set cmbb = cmbRC.Controls.Add(msoControlButton, 211)
cmbb.Caption = "Sort Z-A"
Set cmbb = cmbRC.Controls.Add(msoControlButton, 19)
cmbb.Caption = "Copy"
'The line the BeginGroup draws is one command below were you want it.
cmbb.BeginGroup = True
Set cmbb = cmbRC.Controls.Add(msoControlButton, 21)
cmbb.Caption = "Cut"
Set cmbb = cmbRC.Controls.Add(msoControlButton, 22)
cmbb.Caption = "Paste"
Set cmbb = cmbRC.Controls.Add(msoControlButton, 755)
cmbb.Caption = "Paste Special"
Set cmbb = cmbRC.Controls.Add(msoControlButton, 14782) 'need another action that then opens the Navigation form.
cmbb.Caption = "Close Form"
'The line the BeginGroup draws is one command below were you want it.
cmbb.BeginGroup = True
Set cmbb = cmbRC.Controls.Add(msoControlButton, 502)
cmbb.Caption = "Form View"
'The line the BeginGroup draws is one command below were you want it.
cmbb.BeginGroup = True
Set cmbb = cmbRC.Controls.Add(msoControlButton, 2952)
cmbb.Caption = "Design View"

'Cleanup
Set cmbRC = Nothing
Set cmbb = Nothing
End Sub
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    19th January 2020 - 07:52 AM