Access 2007 - Different Ribbons for Different Users?

B

bcap

This is driving me crazy. Unlike some people, I rather like the Access 2007
ribbon user interface, and I find creating custom ribbons quite
straightforward. BUT what I want to do now is to have different custom
ribbons displayed for different users.

I have a start-up form which pops up a log-on dialog to request a SQL Server
user name and password (I'm using linked tables). I then relink the SQL
Server tables, and check what SQL Server roles the user is a member of. I
now want to display the appropriate ribbon depending on role i.e. Supervisor
users have a different ribbon to Standard users, and so on.

In other words, all I want is to programatically do the equivalent of
changing the Ribbon Name in Access Options. And I simply cannot find any
way of doing this.

Help and suggestions gratefully received!
 
A

Albert D. Kallal

it is quite easy to change the ribbon for a form, just leave the ribbon
setting blank, and then in he forms on-load, simply assign the ribbon for
the form.

if Username = "Super" then
me.RibbonName = "SuperRibbon"
end else
me.Ribbonname = "Standard"
end if
In other words, all I want is to programatically do the equivalent of
changing the Ribbon Name in Access Options. And I simply cannot find any
way of doing this.

Now, for your main startup ribbon, the above might not help, but for forms,
it should work just fine...

I could not find a startup setting for the "main" ribbon. If it is not
possible to change what ribbon shows on startup, then you will have to use
what is called a callback to "enable"/"disable" buttons (and groups) in the
ribbon to achieve your goal.

I have a sample code library that allow you to use the "old" style syntax to
enable/disable controls.

eg:

ribbonname("DeleteButton").enabled = true

You can find it here:
http://www.members.shaw.ca/AlbertKallal/msaccess/msaccess.html
(scroll down to very bottom of page)

The above code is rough, and I NOT had time to write it up, but in place of
waiting until I have time to clean it up, and write it up..I just posting it
for download anyway...
 
B

Baz

Albert D. Kallal said:
it is quite easy to change the ribbon for a form, just leave the ribbon
setting blank, and then in he forms on-load, simply assign the ribbon for
the form.

if Username = "Super" then
me.RibbonName = "SuperRibbon"
end else
me.Ribbonname = "Standard"
end if


Now, for your main startup ribbon, the above might not help, but for forms,
it should work just fine...

I could not find a startup setting for the "main" ribbon. If it is not
possible to change what ribbon shows on startup, then you will have to use
what is called a callback to "enable"/"disable" buttons (and groups) in the
ribbon to achieve your goal.

I have a sample code library that allow you to use the "old" style syntax to
enable/disable controls.

eg:

ribbonname("DeleteButton").enabled = true

You can find it here:
http://www.members.shaw.ca/AlbertKallal/msaccess/msaccess.html
(scroll down to very bottom of page)

The above code is rough, and I NOT had time to write it up, but in place of
waiting until I have time to clean it up, and write it up..I just posting it
for download anyway...

Hi Albert,

Many thanks for your reply.

I have observed that, when I change the ribbon using Access Options, I am
prompted to close and re-open my database in order to apply the change. This
leads me to suspect that it is not possible to dynamically change the
"start-up" ribbon.

I have previously attempted to use the form ribbon without success, but what
I failed to appreciate was that, for the form ribbon to be displayed, there
must be no "start-up" ribbon. If a start-up ribbon is specified, it does NOT
get "overwritten" by the form ribbon.

Now I have discovered this, my problem is solved: I already have a generic
class which sinks certain form events (including the Open event) for every
form in my system so as to apply various generic functionality, so it is a
very simple matter to add some code similar to that which you suggested.
Thank you so much, I've been struggling with this for days.

n.b. I'm about to post another ribbon-related problem, "Standard Ribbon
Tabs in Access 2007 Runtime". Any input to that would be gratefully received.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top