Loss of state of a checkbox or togleButton of a custom ribbon

jacky Perpète 41 Reputation points
2023-09-19T16:25:42.09+00:00

Hello,

From a form, if in the event of a button click, we open a 2nd form followed by the invalidate command from the ribbon, the checkboxes or togleButton lose their selected state.

Here is the test VBA code:

Private Sub cmdOpenForm_Click()

'If Not rbForm1 Is Nothing Then rbForm1.Invalidate ' <=== Here too, it's the same problem

DoCmd.OpenForm "Form2"

If Not rbForm1 Is Nothing Then rbForm1.Invalidate

End Sub

Here is the XML code for the ribbons:

<customUI onLoad="rbForm1_OnLoad" xmlns="http://schemas.microsoft.com/office/2009/07/customui">
    <ribbon startFromScratch="true">
        <tabs>
            <tab id="tabInfo" label="Form1">
                <group id="grpClose">
                    <button idMso="MasterViewClose" size="large"/>
                    <checkBox id="checkBox1"/>
                    <toggleButton id="toggleButton1" label="Test" size="large" imageMso="About"/>
                </group>
            </tab>
        </tabs>
    </ribbon>
</customUI

Here is the process:

  1. Open Form1
  2. Check the checkBox and press the togleButton
  3. Open Form2 using the button on Form1
  4. Close Form2

After this process, the checkBox is unchecked and the togleButton is released.

Here is an illustration:

Ribbon

if the line of code If Not rbForm1 Is Nothing Then rbForm1.Invalidate in VBA is removed, the problem does not exist.

Access
Access
A family of Microsoft relational database management systems designed for ease of use.
336 questions
0 comments No comments
{count} votes