GetLabel on firing on startup

Mister-B

New member
Local time
Today, 15:50
Joined
Apr 10, 2020
Messages
16
In my custom ribbon I use the getLabel function to write data to a button lable.

Code:
Sub GetLabel(control As IRibbonControl, ByRef label)
    ' Callbackname in XML File "getLabel"
    ' To set the property "label" to a Ribbon Control

    Select Case control.ID
    
    Case "Btn_25"
    label = "(" & Form_Daten!Anhang.AttachmentCount & ")"
        ''GetLabel''
        Case Else
            label = "*getLabel*"

    End Select

End Sub

This works fine but unfortunately the data is only written to the lable on startup. When I move through my database I would like the lable to be updated. I am using the ribboncreator from avenius but can't seem to invalidate the control. I can only call the gobjRibbon.InvalidateControl("Btn_25") from the module that contains the code but not from another module (error message). Is there a way to invalidate from the Form_Current procedure or is there another way to force Access to refire getLabel?
 
add another Public Sub on The Same Module where Sub Getlabel is:

Public Sub RefreshBtn25()
gObjRibbon.InvalidateControl "Btn_25"
End Sub

from any form, Current event:

Private Form_Current()
Call RefreshBtn25
End Sub
 
Thanks for the quick answer.

Unfortunately trying to invalidate the ribbon invariably causes an "object variable or with block variable not set" error.
 
causes an "object variable or with block variable not set" error
we can't see your ribbon or the code behind it, so i can't say more.
in my experience, it does not cause error, unless you set it up another way.
 
what i would to is use Tempvars for your label. then on Each form, set the Tempvar value to the "label" you want then Invalidate it.
Code:
Sub GetLabel(control As IRibbonControl, ByRef label)
    ' Callbackname in XML File "getLabel"
    ' To set the property "label" to a Ribbon Control
   
    If IsNull(Tempvars!tvarLabel) Then
        Tempvars.Add "tvarLabel", ""
        Tempvars!tvarLabel = "the Default Label here"
    End IF
   
    Select Case control.ID
   
    Case "Btn_25"
    label = Tempvars!tvarLabel.Value
        ''GetLabel''
        Case Else
            label = "*getLabel*"

    End Select

End Sub

....
....
...
Public Sub RefreshBtn25(Byval sLabel As String)
Tempvars!tvarLabel.Value = sLabel
gObjRibbon.InvalidateControl "Btn_25"
End Sub

from any form, Current event:

Private Form_Current()
Call RefreshBtn25("(" & Form_Daten!Anhang.AttachmentCount & ")")
End Sub
 
Unfortunately, still getting the same "with block" error.
 

Users who are viewing this thread

Back
Top Bottom