jackbenson
asked on
use VBA to load a Ribbon in Access 2010
Hi,
i have a database that is used by different users.
i have create the USysRibbon table and created 2 ribbons.
at the moment in Options.. Curent Database.. i can select a Ribbon to use.
What i hope is that there is some VBA that i can use instead of using the database options so i can load a ribbon.
This way i can load different ribbons for different users.
i have tried DoCmd.ShowToolbar but that did not work.
thanks
jack
i have a database that is used by different users.
i have create the USysRibbon table and created 2 ribbons.
at the moment in Options.. Curent Database.. i can select a Ribbon to use.
What i hope is that there is some VBA that i can use instead of using the database options so i can load a ribbon.
This way i can load different ribbons for different users.
i have tried DoCmd.ShowToolbar but that did not work.
thanks
jack
ASKER
excellent
that works.
you have to have a value set in Options.. Curent Database.. Ribbon Name
otherwise i get an error saying that the Property Does Not Exist when i try to set it.
would be great if there was a way that did not require a re-start.
thanks
jack
that works.
you have to have a value set in Options.. Curent Database.. Ribbon Name
otherwise i get an error saying that the Property Does Not Exist when i try to set it.
would be great if there was a way that did not require a re-start.
thanks
jack
if its a new property you can create one. We can check the error code then create the property if it dont exist.
when you select it manually like you did via Options, Access itself tells you right? Perhaps its because it is something that is loaded on application startup (access internals) and it is not easily configurable when using access. So
when you select it manually like you did via Options, Access itself tells you right? Perhaps its because it is something that is loaded on application startup (access internals) and it is not easily configurable when using access. So
Here is a function to create a new Property:
Public Function SDB_SetProperty(argPrpName As String, argPrpType, argPrpVal)
'ExtName:Set Property
'Actions:Sets the specified database property
On Error GoTo SDB_SetProperty_Error
Dim prp As Property
CurrentDb.Properties(argPr pName) = argPrpVal
SDB_SetProperty = True
SDB_SetProperty_Exit:
On Error Resume Next
Set prp = Nothing
Err.Clear
Exit Function
SDB_SetProperty_Error:
If Err.Number = 3270 Then 'Property not found
Set prp = CurrentDb.CreateProperty(a rgPrpName, argPrpType, argPrpVal)
CurrentDb.Properties.Appen d prp
SDB_SetProperty = True
Else
SDB_SetProperty = False
MsgBox "An unexpected error has occurred: " & Err.Number & " " & Err.Description
End If
GoTo SDB_SetProperty_Exit
End Function
mx
Public Function SDB_SetProperty(argPrpName
'ExtName:Set Property
'Actions:Sets the specified database property
On Error GoTo SDB_SetProperty_Error
Dim prp As Property
CurrentDb.Properties(argPr
SDB_SetProperty = True
SDB_SetProperty_Exit:
On Error Resume Next
Set prp = Nothing
Err.Clear
Exit Function
SDB_SetProperty_Error:
If Err.Number = 3270 Then 'Property not found
Set prp = CurrentDb.CreateProperty(a
CurrentDb.Properties.Appen
SDB_SetProperty = True
Else
SDB_SetProperty = False
MsgBox "An unexpected error has occurred: " & Err.Number & " " & Err.Description
End If
GoTo SDB_SetProperty_Exit
End Function
mx
ASKER
THANKS MX
i am calling the function as follows:
DB_SetProperty "CustomRibbonID", dbText, "TOOLS"
where "TOOTS" is the name of my ribbon
but i get the following message - Type Missmatch
the problem is caused on this line of code:
Set prp = CurrentDb.CreateProperty(a rgPrpName, argPrpType, argPrpVal)
what is the correct value for argPrpType that i should be passing?
thanks
jack
i am calling the function as follows:
DB_SetProperty "CustomRibbonID", dbText, "TOOLS"
where "TOOTS" is the name of my ribbon
but i get the following message - Type Missmatch
the problem is caused on this line of code:
Set prp = CurrentDb.CreateProperty(a
what is the correct value for argPrpType that i should be passing?
thanks
jack
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
CurrentDb.Properties("Cust
db usually requires a restart to see the changes though