"Norman" wrote in message
news:52ef90cc-da62-4a06-860d-498e5fa02e81 (AT) k5g2000pra (DOT) googlegroups.com...
Quote:
frmGlobals!GetVisible = False
gobjRibbon.InvalidateControl ("grp3")
frmGlobals!GetVisible = True
gobjRibbon.InvalidateControl ("cmd22")
In the above code, I'm trying so set grp3 to not visible and cmd22 to
visible. The hidden form 'Globals' holds the True or False value. If
I only execute one set or the other, no problems. When I do them both
as shown, both grp3 and cmd22 are set to True. In other words,
gobjRibbon.InvalidateControl ("cmd22")
appears to be updating grp3 as well, not just cmd22.
What am I doing wrong.
Thanks,
Norman |
This does look like you are using the SAME variable or value from that
global form for different controls.
You can't really do that. In effect you need a separate individual variable
for every control on the ribbon
that you intended to control. (you need a var to hold the "value" or state
of the control in question).
While in "most" cases a invalidate of single control should be limited to
the one control, any other type of refresh
of that ribbon means that ALL of the controls routines fire. IN other words
while you only invalidate the one control, often the system will run the
code for all controls.
And while your code is attempting to work with one control, what about when
the ribbon loads? And what about when the whole ribbon and NOT a control in
invalided. When the ribbon controls "ask" your code for the state or status
of a value, ALL OF the controls will do this, not necessary just one
control. And even in your case if the ribbon was limited to one control,
quite much every control and every routine is called during a ribbon load.
Thus quite much means you cannot use the SAME variable to hold the state of
more then ONE control on the ribbon.
I see in your code snip you using
frmGlobals!GetVisible = True
The problem here is you trying to use the "same" value from that form for
different controls.
You need separate values for each control. The on/off state is required to
be kept at all times. In other words it is your code that supplies these
values to the ribbon.
You have to declare and define a separate variable for EACH control on the
ribbon.
So if you using enable/disable, label text, and visible? That would mean 3
separate global vars are needed.
This can become enormously tedious if you have several ribbons and have just
even 4-5 controls on 3 ribbons.
The math is this:
3 ribbons x 5 controls * 3 vars = 45 variables you going to need here. And
if you control 4 features of a single control, you can see how complex this
will become.
Because of the above, I built a class object that builds the vars on the fly
at runtime (uses a custom collection object).
The result is you don't ever need to declare any variables for controlling
the ribbon.
I also allow use of the "older" command bars syntax to enable controls (so
this was built for migration of older applications).
So my code for what you have above would be:
meRib("grp3).Visible = False
meRib("cmd22").Visible = true
The invalidate and creating of variables is thus automatic (and the setup is
designed for use with runtime applications also).
You can find my article and the code download for this here:
Some code to tame the Office Ribbon for Access
http://www.kallal.ca/Ribbon/ribbon.htm
If you use a accDE then any un-handled errors will NEVER re-set the global
collection object I use to manage this issue. However, if you don't
distribute a accDE, then any error will re-set my global class object and
for this reason I always assume you using a accDE here as then any and all
global vars ALWAYS remain intact for the running instance of that
application.
--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
Pleasenospam_kallal (AT) msn (DOT) com