Ribbon

  • Follow


I have succeeded in using Albert D Kallal ' s brilliant code to control a
Ribbon on a form.
The only problem I cannot solve is how to make some buttons invisible when
the form loads.
If I put the meRib("btSearch").visible = False in Form_Active or Form_Current.

I get the runtime error '2475' you entered an expression that requires a form
to be the active window.
Any suggestions would be great.

-- 
Message posted via http://www.accessmonster.com

0
Reply TonyAntique 5/31/2010 8:20:37 PM

first make sure you have an onLoad="OnRibbonLoad" to start for your ribbon 
item.

<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui"  
onLoad="OnRibbonLoad"  >

the vba:
Public Sub OnRibbonLoad(objRibbon As IRibbonUI)
    Set gobjRibbon = objRibbon
End Sub

second for the object(button/toggle, etc.) will need to add a 
getEnabled="Somename" ' name of the code it will call

<button id="cmdADV" getVisible="GetVisible" /> ' leaving out other useful 
ribbon attributes for clarification.

vba:
Public Sub GetVisible(ctl As IRibbonControl, ByRef Visible As Variant)
gobjRibbon.Invalidate

Select Case ctl.ID ' what ribbon property will be used to find items to enable
    Case "cmdADV": Set Visible = Forms![Firm_Address]![IA] 'reason visible
   Case "cmdCE": Set Visible = Forms![Firm_Address]![BD] 'other button 
id(s), uses the same code
   Case "grpChecklist": Set Visible = [Forms]![WSP_RegCat_Select]![Check2]
End Select

End Sub

in this code you will notice it uses Case, so in essence you can load all 
items into one Sub referenced by their "id."  of course the reason/value you 
use to 
enabled/disabled is up to you.

without going to much else farther you can replace ID, with Tag so maybe you 
have a bunch of similar function buttons that will be visibleat the same 
time.  GetEnable works almost the same way.

hope that helps, i will try to watch for any response, i dont recieve the 
emails anymore.

"TonyAntique via AccessMonster.com" wrote:

> I have succeeded in using Albert D Kallal ' s brilliant code to control a
> Ribbon on a form.
> The only problem I cannot solve is how to make some buttons invisible when
> the form loads.
> If I put the meRib("btSearch").visible = False in Form_Active or Form_Current.
> 
> I get the runtime error '2475' you entered an expression that requires a form
> to be the active window.
> Any suggestions would be great.
> 
> -- 
> Message posted via http://www.accessmonster.com
> 
> .
> 
0
Reply Utf 6/2/2010 4:42:58 PM


1 Replies
516 Views

(page loaded in 0.031 seconds)

Similiar Articles:
















7/26/2012 2:58:54 AM


Reply: