[ Team LiB ] |
Recipe 16.3 Display Smart Tags when Application Starts16.3.1 ProblemMy 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? 16.3.2 SolutionThe 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. Figure 16-5. Setting smart tag viewing optionsThe 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. Figure 16-6. Configuring a startup formFollow these steps in your startup form to ensure that smart tags are displayed for your application:
16.3.3 DiscussionBy 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 You can test the code by opening frmStartup and frmTest side by side. You can see the smart tags on both forms enabled or disabled as you click the Toggle Smart Tags button on frmStartup. |
[ Team LiB ] |