I have the following public variable declared in a module:
Then I have a function that runs from AutoExec and creates a xml statement and sets it as the default ribbon for the database:
Then every now and then I use the following to re-assign the ribbon, hide/show/enable/disable buttons & controls:
This is working, not even a single problem.
But if an unhandled error occurs, the public variable is destroyed (if it's the correct terminology) and the next time the code tries to invalidate the ribbon, it returns the following error:
Object variable or With block variable not set
Now my question:
Any kind of insight is much appreciated.
Code:
Option Explicit
Public OrdersRibbon As IRibbonUI
Then I have a function that runs from AutoExec and creates a xml statement and sets it as the default ribbon for the database:
Code:
Public Function LoadRibbons()
.....
' create the xml
.....
Application.LoadCustomUI "OrdersRibbon", strXML
.....
End Function
Then every now and then I use the following to re-assign the ribbon, hide/show/enable/disable buttons & controls:
Code:
OrderRibbon.Invalidate
OrderRibbon.InvalidateControl (MyControlID)
This is working, not even a single problem.
But if an unhandled error occurs, the public variable is destroyed (if it's the correct terminology) and the next time the code tries to invalidate the ribbon, it returns the following error:
Object variable or With block variable not set
Now my question:
- Is there any other way than a public variable to use in above case? I mostly use tempVars. But I've never set an object to a tempVar nd I'm not sure how to use it in above case.
- Is there any way to re assign a public variable once it's been destroyed? (at present we have to close and re-open the database)
Any kind of insight is much appreciated.
Last edited: