Link to home
Create AccountLog in
Avatar of flsolo
flsolo

asked on

MS Access 2010 ribbon

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!!
Avatar of Brian Pierce
Brian Pierce
Flag of United Kingdom of Great Britain and Northern Ireland image

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
Avatar of flsolo
flsolo

ASKER

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
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
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
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
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.
Avatar of flsolo

ASKER

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!
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?
Try this one
I think the buttons behave as you'd like
Nick1.accdb
Avatar of flsolo

ASKER

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!
ASKER CERTIFIED SOLUTION
Avatar of Nick67
Nick67
Flag of Canada image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account