|[ Team LiB ]|
Recipe 16.3 Display Smart Tags when Application Starts
My application makes extensive use of smart tags. Since this is a global setting, some users may have turned off the display of smart tags. How can I ensure that smart tags are displayed when my application starts up?
The display of smart tags is controlled by a checkbox in the Tools Options dialog box under the Forms/Reports tab. These settings apply to Access as a whole, and once changed, take effect for all running applications. Figure 16-5 shows the dialog box with the display of smart tags turned on.
The best place to set options for your application is in a startup form, which can run code to ensure that settings are the way you need them to be. The sample application is configured to use a form named frmStartup, by setting the Display/Form Start Page property in the Tools Startup dialog box, as shown in Figure 16-6.
Follow these steps in your startup form to ensure that smart tags are displayed for your application:
By saving the smart tag settings in a variable, you can ensure that your application behaves in a polite way, only changing the user's global settings that are needed for your application to function properly. In the sample application, the code in the Close button event handler closes the form and resets the user's smart tag options to whatever they were when the application opened. You could elect to simply hide the form instead:
Private Sub cmdClose_Click( ) Me.Visible = False End Sub
The code in the form's Close event will not execute if the form is hidden and not closed. When the application shuts down, the form closes and the code in its Close event runs and resets the user's smart tag options to their original values.
The frmStartup form in the sample database also contains a Toggle Smart Tags button that toggles the display of the smart tags option. The ToggleShowSmartTags procedure reverses the current option settings for displaying smart tags and stores the new setting in the varSmartTagOn variable:
Private Sub ToggleShowSmartTags( ) ' Toggle smart tag settings varSmartTagOn = Not varSmartTagOn Application.SetOption "Show Smart Tags on Forms", varSmartTagOn MsgBox "Application Settings = " & varSmartTagOn, , "Show Smart Tags" End Sub
|[ Team LiB ]|