View Full Version : Queries and Ribbons


mikemaki
02-05-2010, 12:03 PM
We are converting a charges database from 2003 to 2007. it has few reports. Most of the reporting is done by opening queries in datasheet view and using a toolbar, exporting it to Word, Excel, etc. Now we will be using a ribbon. Is tthere a way to relate a query to a ribbon or change the ribbon being used via VBA?

vbaInet
02-05-2010, 12:10 PM
Here are some good links on how to create ribbons and using calling backs to perform actions:

http://msdn.microsoft.com/en-us/library/aa338202.aspx
http://www.accessribbon.de/en/
http://ribbon.anirdesh.com/Controls.html

mikemaki
02-05-2010, 12:23 PM
Thanks for the quick response, but the ribbons are already created. We just want to use the secure ribbon that cotains no tabs until the queries are opened in datasheet view. Then we want to switch to the export ribbon.

vbaInet
02-05-2010, 12:30 PM
It would be a matter of changing the name of the ribbon. I'm guessing you're using the USysRibbons table to store the xml for your ribbon?

You can set the ribbon, like this:

NameOfQuery.RibbonName = "NameOfRibbon"

How is your query called?

mikemaki
02-05-2010, 12:34 PM
DoCmd.OpenQuery stDocName, acNormal, acEdit

vbaInet
02-05-2010, 12:39 PM
DoCmd.OpenQuery stDocName, acNormal, acEdit

With queries it's a difficult one because they don't have events as such. My advice would be to create a form that is based on that query and set it to Datasheet view. Then you can set the RibbonName property. Sounds like a plan?

SOS
02-05-2010, 12:41 PM
Or, use code (don't have a clue what code) to set it just before this line:

DoCmd.OpenQuery stDocName, acNormal, acEdit

mikemaki
02-05-2010, 12:41 PM
Thanks, I'll try it Monday.

vbaInet
02-05-2010, 12:44 PM
It would interesting to hear how it went. Good luck.