Solved

MS Access 2010 ribbon

Posted on 2013-05-16
12
1,039 Views
Last Modified: 2013-05-27
Hello,
I would like to be able to disable / enable (in code) some of the built-in buttons, e.g. "Print" or "Quick Print" in my custom ribbon in MS Access 2010.

Example would be much appreciated.

Thanks!!
0
Comment
Question by:flsolo
  • 8
  • 3
12 Comments
 
LVL 70

Expert Comment

by:KCTS
ID: 39173285
0
 
LVL 26

Expert Comment

by:Nick67
ID: 39173330
The Q noted by KCTS is very long.
But at the end of it, you should have a very good idea of what's involved in customizing the Ribbon.

Now, your question was  
I would like to be able to disable / enable (in code) some of the built-in buttons, e.g. "Print" or "Quick Print" in my custom ribbon in MS Access 2010.

I wouldn't do that.  Since you've got a custom ribbon on the go, I'd populate it with buttons aimed at macros/code that do what YOU want.  That will give you the level of control that you want, without having to fight the system's built in tendency to think that it knows what's best.

A sample db from you would be most helpful.

Nick67
0
 

Author Comment

by:flsolo
ID: 39180640
Nick67,
Attached is the ms access db with all buttons on one ribbon. There is a button "Test 2" which works exactly as I need to - it is a custom button. I need to get working built-in buttons "Print" and "Quick Print" the same way, i.e. enable them when any report is shown and disable them when Form1 is shown.

Any help is appreciated.
Thank you.
Test2.zip
0
 
LVL 26

Expert Comment

by:Nick67
ID: 39184934
I'll have a look at it this evening, but
I need to get working built-in buttons "Print" and "Quick Print" the same way
will be ultimately self-defeating.  Those buttons will only work the way MS wants them to.  Your only simple choices are to hide built-in buttons, or display them and let them work the way MS intended.  While it may not be technically impossible to figure out which built-in button was pressed, cutoff its event at the knees, and substitute your own event, it's REALLY not going to be worth the effort
0
 
LVL 26

Expert Comment

by:Nick67
ID: 39184985
If you REALLY have to have that kind of functionality, and have access to VSTO then you can take a gander at this
http://msdn.microsoft.com/en-us/library/vstudio/bb608623.aspx
0
 
LVL 26

Expert Comment

by:Nick67
ID: 39186491
Alright here's a little jiggery-pokery of the Ribbon and BackStage
The Print and Quick Print look like they're MS's, but they are ours.
I am not at all sure that your events are working the way you desire, but I have put some msgboxes into them to show they are firing.  Control.tag seems to be empty, so nothing goes on.

I have hidden the BackStage, but it throws a one-time unhappy error when accessesd from an open form, whining about TabShare  The USysRibbons XML has been formatted for legibility.  You also have a control disabling problem when you close out a report--the Ribbon controls are NOT disabled until a new object is actually made the focus.

Let me know what you think.

Nick67
Nick1.accdb
0
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
LVL 26

Expert Comment

by:Nick67
ID: 39186537
Alright,
That BackStage error existed in your original as well.
To get rid of it, look here
http://social.msdn.microsoft.com/Forums/en-US/accessdev/thread/c058c185-4076-4670-b7eb-b51100a10388

In Options | Client Settings turn off Show add-in user interface errors

Because the forms don't have a share tab, what you've done to pare down BackStage pops an error when a non-existent tab is made invisible.
0
 

Author Comment

by:flsolo
ID: 39187783
Nick67,
Thanks for noticing that error, it has never happened to me.

The database Nick1.accdb works the way I want (for enabling / disabling print and quick print buttons), but when the report is shown, print button enabled and clicked, I want to show the print dialogue. Is it possible? The same with quick print - when enabled and clicked it prints (the report) to the windows default printer.

Thanks!
0
 
LVL 26

Expert Comment

by:Nick67
ID: 39188162
In Options | Client Settings turn off Show add-in user interface errors
From the look of the thread I posted, that option is set on a machine basis.  If it is off on your machine already, then you would have never seen the error.

The quick print should be  straight forward
DoCmd.OpenReport Screen.ActiveReport.Name, acViewNormal
ought to do it.

But if you liked the functionality behind those two print buttons, my customization of them was unnecessary.  You just need the Select Case True logic that I have set up to disable the MS buttons -- which is entirely doable.

You'd add the BackStage disablement XML to your existing USysRibbons so that no one can print from BackStage, and alter the Select Case True logic to point at the existing MS id's and not FakePrint and FakeQuickPrint

You could invoke a FileDialog object and its assorted rigamarole...but if you are perfectly happy with what MS's button does, why re-invent the wheel?
0
 
LVL 26

Expert Comment

by:Nick67
ID: 39189756
Try this one
I think the buttons behave as you'd like
Nick1.accdb
0
 

Author Comment

by:flsolo
ID: 39199169
Nick67,
Thanks for your post again, yes the buttons works the way I want. You deserve the points already, but would you please show me (db example is the best) how to do it with standard MS buttons as mentioned in your last post (that was my original question)?

Thanks!
0
 
LVL 26

Accepted Solution

by:
Nick67 earned 400 total points
ID: 39199314
I did poke at that a bit...to learn that the MS buttons will NOT permit themselves to be disabled.  Apparently the idMSO bit in the XML tells the system to pointedly ignore anything the VBA code may tell it to do.

Ribbons are funny objects to manipulate with VBA.  The code doesn't behave the way you'd expect.  Putting breakpoints in the disablement code was useless.  The code would not stop for them.  Msgbox's worked, so you could see the code was firing, but the breakpoint would just be completely ignored.

You've got what you need--buttons that look like the MS ones but behave the way you want.
There is a listing of all the imageMso strings here
http://msdn.microsoft.com/en-us/library/dd953682(v=office.12).aspx
and a gallery of them here
http://soltechs.net/CustomUI/imageMso01.asp?gal=1&count=no
Which is certainly a lot more documentation than existed at the time that Q27231448 was posted.

So you should be able to mock up any MS button and make it behave how you want, which is certainly what the doctor ordered.  I think any effort to leave the idMso intact but then try to manipulate the resulting button will be wasted effort.

Nick67
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We were having a lot of "Heartbeat Alerts" in our SCOM environment, now "Heartbeat" in a SCOM environment for those of you who might not be familiar with SCOM is a packet of data sent from the agent to the management server on a regular basis, basic…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now