Dynamic RibbonXML (1 Viewer)

Timax

Registered User.
Local time
Today, 01:12
Joined
May 14, 2015
Messages
33
Hi everyone! Need your help on creating dynamic RibbonXML where statement will depend on user that is accessing access database. I created DynamicXML no problem and it changes context depending on user but my main problem is refreshing ribbon. I see that UsysRibbons tables changes fine but it's not being loaded. I have to restart access in order to this to take effect. I tried gobjRibbon.Invalidate method but it doesn't refresh ribbon for some reason... Here is my code:

I created new module with name "Ribbon" and put this in there:

Option Compare Database
Option Explicit
Public gobjRibbon As IRibbonUI

Public Sub CallbackOnLoad(Ribbon As IRibbonUI)
' Callbackname in XML File "onLoad"
Set gobjRibbon = Ribbon
End Sub

and then in form that validates a user I put:

If (Not gobjRibbon Is Nothing) Then
gobjRibbon.Invalidate
End If

No success... What am I doing wrong?
 
Last edited:

Ari

Registered User.
Local time
Today, 01:12
Joined
Oct 22, 2011
Messages
139
Hi

You must use the attributes get's (getVisible, getEnabled, ...) to change your ribbon dynamically. Paste here the XML of your ribbon.

We wait
 

Timax

Registered User.
Local time
Today, 01:12
Joined
May 14, 2015
Messages
33
Hi, I tried to use getVisible but no success... Here is my XML:

<customUI xmlns="xxxxxxCanNotUseLinksHerexxxxxxi"
onLoad="CallbackOnLoad">
<ribbon startFromScratch="false">
<tabs>
<tab id="tab1" label="Operations" >
<group id="grp2" label="Login" >
<button id="OpenForm1" size="large" label="Time Log" tag="Log" imageMso="HeaderFooterCurrentTimeInsert" onAction="Log" />
</group>
<group id="grp3" label="Departments" >
<button id="OpenForm2" size="large" label="RFQ" tag="RFQ" imageMso="GroupBlogProofing" onAction="RFQ" />
<button id="OpenForm3" size="large" label="Accounting" tag="SecurityOrders" imageMso="GroupBlogProofing" onAction="SecurityOrders" />
<button id="OpenForm4" size="large" label="Purchasing" tag="SecurityQuote" imageMso="GroupBlogProofing" onAction="SecurityQuote" />
<button id="OpenForm5" size="large" label="Production" tag="Production" imageMso="GroupBlogProofing" onAction="Production" />
<button id="OpenForm6" size="large" label="Stock Room" tag="Auditing" imageMso="GroupBlogProofing" onAction="Auditing" />
<button id="OpenForm7" size="large" label="RMA" tag="SecurityRMA" imageMso="DeclineInvitation" onAction="SecurityRMA" />
</group>
<group id="grp4" label="General" >
<button id="OpenForm8" size="large" label="Stencils" tag="SecurityStencils" imageMso="Drawing1GalleryBrightness" onAction="SecurityStencils" />
<button id="OpenForm9" size="large" label="Reports" tag="Report" imageMso="Chart3DColumnChart" onAction="Report" />
<button id="OpenForm10" size="large" label="Admin" tag="Adminka" imageMso="AdpPrimaryKey" onAction="Adminka" />
</group>
</tab>
</tabs>
</ribbon>
</customUI>

I created login form that evaluates the access level of each user and depending of the access level I am constructing XML to that user and loading it into UsysRibbon table. Everything works only when I restart access but can not make it update after Ribbon is loaded and this start up form is on. What am I doing wrong? Thank you
 

Ari

Registered User.
Local time
Today, 01:12
Joined
Oct 22, 2011
Messages
139
Hi

What is your version of Access? I'll give you an example, which will control the Group Department of your Ribbon, using the getVisible attribute.

<group id="grp3" label="Departments" getVisible="fncGetVisible" >
 

Timax

Registered User.
Local time
Today, 01:12
Joined
May 14, 2015
Messages
33
I am using Access 2013 with MS SQL 2008 and some stations have runtime Access installed
 

Ari

Registered User.
Local time
Today, 01:12
Joined
Oct 22, 2011
Messages
139
Hi

follows the example file

- Note the use of INVALIDATE through the event "after update" group options.
- Note the fncGetVisible () function changing the grp3 group

Public Sub fncGetVisible(control As IRibbonControl, ByRef visible)
On Error GoTo fError
Select Case control.Id
Case "grp3"
visible = Forms!frmMain!Status
...
...
 

Attachments

  • Timax.zip
    38.6 KB · Views: 102

Timax

Registered User.
Local time
Today, 01:12
Joined
May 14, 2015
Messages
33
Hi Ari! thank you very much for your help and for your code!!! I managd to make it work with your help finally. I have 2 questions if you don't mind. First of all, is there way to control <ribbon startFromScratch="true"> in UsysRibbon XML code true/false value via code depending on users access level? Second question is that I have:
Select Case control.ID
Case "OpenForm1"
visible = DLookup("[TLG]", "Departments", "[ID] = " & Forms!Security_start!Text3)

visible get value from form control as you designed on your example but I want to close form after user enters password but it doesn't work. My problem is that this code runs after form closes and it looking for it. At what point and where in the code I can close form that have value for visible parameter or I shouldn't base it in form control? What approach I should take? Thank you in advance
 

Users who are viewing this thread

Top Bottom