Color scheme: Dark
You are here: start » en » Documentation » Microsoft Access development tools » WKL Forms Object Library » WKL Forms Object Library how-to guides » How to: Show commands only in development

How to: Show commands only in development

Show a command (or a whole group, tab, or File view tab) only in the development profile, only in the ACCDB file, or only to users the application allows.

Requires WKL Forms Object Library 1.49 or later.

Solution overview

Every command, tab, group, and File view tab in the ribbon model has a condition with three parts, all of which must hold: Profiles (the Linked Tables Manager's connection profile), the kind of file (ACCDB, ACCDE, or runtime), and Function (a public VBA function without arguments that returns True). An empty part doesn't restrict anything.

Implementation

In the ribbon designer, select the command (on the Commands page) or the group (on the Ribbons page) and fill in Visible when, for example:

GoalProfilesKind of fileFunction
Developer toolsDEVACCDB
Administrators onlyIsAdmin
Never in the runtimeACCDB, ACCDE

The function for the condition:

Public Function IsAdmin() As Boolean
    On Error Resume Next
    IsAdmin = Nz(TempVars("role"), "") = "Admin"
End Function

After the sign-in sets the role, have the ribbon ask again:

TempVars("role") = "Admin"
WklRibbonObject().Invalidate

Remarks

  • The profile is the one set with WklRibbonObject().Profile; otherwise, it's the profile that most linked tables use (as with WklLinkManager.DetectEnvironment). A database without a link configuration has an empty profile, so a condition with a profile hides the element there.
  • The kind of database is determined once per session: the runtime counts first (an ACCDE file in the runtime counts as “runtime”), then ACCDE, and otherwise ACCDB.
  • The function is called whenever Access queries the element, so keep it fast and give it its own error handling.
  • Hiding is a convenience, not security: anyone who can open the database can run the action. Check permissions in the data source.
en/wiki/msaccess/comctl/how-to/show-commands-only-in-development.txt · Last modified: by Wolfgang van der Stille