Set up the start of an application for its three modes
In this tutorial, you use the application designer to give a small database a title, an icon, and a startup form, keep the defaults for the three modes, and confirm in an ACCDE file that the special keys are turned off. It takes about ten minutes and one line of VBA.
Prerequisites
- Microsoft 365 Access, 32-bit or 64-bit, with the WKL Forms Object Library 1.51 or later installed and registered for the current Windows user (How to: Install the released package).
- The WKL Extensions add-in installed, so that Database Tools › Add-Ins offers WKL Application Designer:
tools\install-addin.ps1in the release package (1.55 or later) installsaddin\WklExtensions.accdafor the current user. Without the add-in, you can also open the designer from the Immediate window:CreateObject("WklForms.Application").ShowDesigner. - A database in a trusted location with a form
frmStart, and an icon file (.ico) of your choice.
Steps
1. Open the designer
Choose Database Tools › Add-Ins › WKL Application Designer. The designer opens on the General page; the preview on the right shows the title bar.
2. Set the title, icon, and startup form
- Under Title, type Customers; the preview updates as you type.
- Under Icon file, click Choose … and select the icon file. Its file name appears under Icon; the file is stored in the database when you click OK.
- Under Start form, choose frmStart.
3. Review the modes
Open the Modes page. Each row is a startup option and each column a mode; a check mark allows or shows the option in that mode. Keep the defaults: development allows everything; administration has no design commands, special keys, or Shift bypass; and production also hides the navigation pane and the built-in Access shortcut menus. Defaults restores the defaults after a change.
4. Check and save
Open the Check page: it reports Ready to save. Click OK. The Access title bar immediately shows Customers with your icon; the other options take effect the next time the database opens.
5. Correct the mode at every startup
Open the module of frmStart and add:
Private Sub Form_Load()
Dim findings As String
findings = CreateObject("WklForms.Application").EnsureApplication()
If Len(findings) > 0 Then Debug.Print findings
End Sub
EnsureApplication writes the startup options for the mode the database runs in and returns what
it noticed (for example, a missing startup form). It never stops the startup.
6. Try the administration mode
- Choose File › Save As › Make ACCDE and save the file as
Customers.accde. - Open
Customers.accde, close it, and open it again: the first opening wrote the options for the administration mode, and the second one shows them. - Press Ctrl+G: the VBA editor doesn't open. Hold down Shift while opening the file:
frmStartopens anyway.
Expected result
The ACCDB file opens with everything a developer needs; the ACCDE file opens with the title, the
icon, and frmStart, but without design commands, special keys, or the Shift bypass. The model is
stored in the database's USysWklApp table (open the designer again to see it).
Next steps
- How to: Deliver an application for production: a delivered copy that's set up correctly the first time it opens.