Change ribbon from subform (1 Viewer)

zelarra821

Registered User.
Local time
Today, 17:53
Joined
Jan 14, 2019
Messages
813
Hello. I have a form with a subform. I am trying to achieve, through a class module, that the ribbon of the main form changes when entering a textbox of the subform. I have tried

Form.Parent.RibbonName = "RichText",

but it gives me an error, and I don't know how else I can put it.

Thank you so much.
 

jdraw

Super Moderator
Staff member
Local time
Today, 11:53
Joined
Jan 23, 2006
Messages
15,379
I recommend you post the database, or a shortened version, showing the class and usage. Highlight how to repeat/show the condition involved and your expectation. Always good to show the before and after values to help with context.
Also good to post the error you encountered.
 

zelarra821

Registered User.
Local time
Today, 17:53
Joined
Jan 14, 2019
Messages
813
I attach an example with two forms: one with a subform (where the problem is), and another without a subform so you can see the behavior it should have.

You also have a small video commenting on the problem.
 

Attachments

  • Database.accdb
    1.3 MB · Views: 58
  • Video.zip
    1.8 MB · Views: 54

MarkK

bit cruncher
Local time
Today, 08:53
Joined
Mar 17, 2004
Messages
8,181
There are errors in your ribbon XML. To get Access to raise those errors so you can correct them, open the Access Options form, Client Settings, General section, and enable the "Show add-in user interface errors" option. Then, next time you start your database, you'll see a number of errors are raised before any code runs. You have duplicate control IDs, unknown elements, etc..., in your XML.
hth
 

MarkK

bit cruncher
Local time
Today, 08:53
Joined
Mar 17, 2004
Messages
8,181
This ribbon, named ViewReport, has two ribbon elements and duplicate IDs...
Code:
<?xml version="1.0" encoding="utf-8"?>
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
  <ribbon startFromScratch="true">
<tabs>
<tab id="T001" label="Formato de texto">
<group idMso="GroupTextFormatting">
</group>
</tab>
</tabs>
</ribbon>

<ribbon startFromScratch="true">
<tabs>
<tab id="T001" label="Salir">
<group id="T001G001" label="Salir">
<button id="Copiar texto sin formato" label="Copiar texto sin formato" imageMso="MasterViewClose" size="large" supertip="Copiar texto sin formato" onAction="rbSalir" />
</group>
</tab>
</tabs>
</ribbon>
 

zelarra821

Registered User.
Local time
Today, 17:53
Joined
Jan 14, 2019
Messages
813
I have solved two of the three problems with the ribbon, but I have no idea about the third one, because I don't know where the problem is.

Regarding the problem I raised at the beginning, it still does not work, as it is as if the main form ribbon was not updated.
 

Attachments

  • Database.accdb
    1.3 MB · Views: 59

MarkK

bit cruncher
Local time
Today, 08:53
Joined
Mar 17, 2004
Messages
8,181
In your USysRibbons table, the row having RibbonName = "ViewReport", the RibbonXML has two <ribbon> elements. There can only be one.
 

zelarra821

Registered User.
Local time
Today, 17:53
Joined
Jan 14, 2019
Messages
813
Ok, I have already fixed USysRibbons table and I don't get any errors. I am attaching the database so you can see for yourself.

I thank you very much for having the detail to inform me of those errors in the ribbons that I have created.

Now, this doesn't solve the problem I came here for: I'm not able to change the ribbon when I enter a textbox in the subform, and return it when I change when I exit the textbox.

I have used:

Form.Parent.RibbonName = "RichText"

But it doesn't do anything.

I have put some MsgBox to check that it actually got the ribbon I wanted correctly, but it is as if the ribbon of the main form was not updated correctly.

You can help?

Thank you very much again.
 

zelarra821

Registered User.
Local time
Today, 17:53
Joined
Jan 14, 2019
Messages
813
Sorry
 

Attachments

  • Database Ribbon fixed.accdb
    1.3 MB · Views: 62

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 23:53
Joined
May 7, 2009
Messages
19,245
i did not check your mouse class.
i commented it out and the ribbon is now showing.
 

Attachments

  • Database Ribbon fixed.accdb
    1.3 MB · Views: 57

zelarra821

Registered User.
Local time
Today, 17:53
Joined
Jan 14, 2019
Messages
813
Thank you very much, it is an option, but I wanted to do it through the class module.

However, thanks to your example, I have understood that the ribbon displayed is that of the form that is active, it does not matter if it is a main form or a subform. Therefore, I don't have to put:

Form.Parent.RibbonName

in the case of the subform, but directly:

Form.RibbonName

And that solves the whole problem.

Thank you very much you two.

MarkK for helping me correct the errors in my custom ribbons, and arnelgp for giving me an example that helped me realize my mistake and be able to fix it.

Greetings.
 

Users who are viewing this thread

Top Bottom