GetLabel on firing on startup (1 Viewer)

Mister-B

New member
Local time
Today, 18:07
Joined
Apr 10, 2020
Messages
10
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?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 00:07
Joined
May 7, 2009
Messages
19,246
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
 

Mister-B

New member
Local time
Today, 18:07
Joined
Apr 10, 2020
Messages
10
Thanks for the quick answer.

Unfortunately trying to invalidate the ribbon invariably causes an "object variable or with block variable not set" error.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 00:07
Joined
May 7, 2009
Messages
19,246
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.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 00:07
Joined
May 7, 2009
Messages
19,246
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
 

Mister-B

New member
Local time
Today, 18:07
Joined
Apr 10, 2020
Messages
10
Unfortunately, still getting the same "with block" error.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 00:07
Joined
May 7, 2009
Messages
19,246
Unfortunately, still getting the same "with block" error.
post your "ribbon" xml code.
see this demo.

open each form and see the label changes.
 

Attachments

  • sample_ribbon_label.accdb
    956 KB · Views: 78
Last edited:

Users who are viewing this thread

Top Bottom